The output of
ls (with no arguments) appears to separate filenames with linebreaks.
ls | grep fooworks as expected, with
greptreating each filename as a separate line of input.
ls > files.txt; vim files.txt--> in Vim, each file is on a separate line
And yet in the terminal the output of
ls puts multiple files on one line, separating the filenames with spaces to make nicely aligned columns:
$ ls a.txt b.txt c.txt
So my question is, how does ls do this?
Is it using some special control char to 'fake' a newline? Or does it know when its output is being piped to another command, and format its output differently in this case?