Why echo splits long lines in 80 chars when printing within quotes? (And how to fix it?)
问题 Echoing without quotes... 1 line. Fine. $ echo $(ls -1dmb /bin/*) > test $ wc -l test 1 test Echoing with quotes... 396 lines. Bad. $ echo "$(ls -1dmb /bin/*)" > test $ wc -l test 396 test The problem comes when using echo for writing a file and expanding a long variable. Why does this happen? How to fix it? 回答1: ls is detecting that your stdout is not a terminal. check the output of ls -1dmb /bin/* | cat vs ls -1dmb /bin/* . It's ls , who is splitting the output. Similarly, for ls --color