Look at the diffreent output of ls
versus ls -1
$ ls
filea1.txt fileb.txt listB1.xml listC.xml
filea.txt listA1.xml listB.xml 'name with spaces 2.txt'
fileb1.txt listA.xml listC1.xml 'name with spaces.txt'
$ ls -1
filea1.txt
filea.txt
fileb1.txt
fileb.txt
listA1.xml
listA.xml
listB1.xml
listB.xml
listC1.xml
listC.xml
'name with spaces 2.txt'
'name with spaces.txt'
Which is quite OK for me. Thing go different if you redirect the output to file. I'd expect that file diffes, but they are identical.
$ ls -1>/tmp/ls-1.out
$ ls >/tmp/ls.out
$ cat /tmp/ls-1.out
filea1.txt
filea.txt
fileb1.txt
fileb.txt
listA1.xml
listA.xml
listB1.xml
listB.xml
listC1.xml
listC.xml
name with spaces 2.txt
name with spaces.txt
$ cat /tmp/ls.out
filea1.txt
filea.txt
fileb1.txt
fileb.txt
listA1.xml
listA.xml
listB1.xml
listB.xml
listC1.xml
listC.xml
name with spaces 2.txt
name with spaces.txt
Why is the latter just one-column output but not the multi-column as when there's no redirection to file?
. If the output is to a terminal, the format is implementation-defined.
<<< that's the point not really mentioned in man. – Tagwint Jul 25 '18 at 10:41ls
know if the output is a terminal? – Jaime Hablutzel Feb 22 '22 at 08:38isatty
to check whether its standard output is a terminal. – Stephen Kitt Feb 22 '22 at 08:43