On Thu, Oct 30, 2025 at 2:17 PM Van Snyder <[email protected]> wrote:
> ls lists files one-per-line if its output is piped other than stdout
Not always.
How 'bout three lines for one file:
$ ls | cat
three
line
file
$ ls
'three'$'\n''line'$'\n''file'
$ man ls | col -b | expand | grep -e '-1.*one'
-1 list one file per line
$ ls -1 | cat
three
line
file
$
Don't believe everything you think ... or even necessarily read in the
documentation. Even though the documentation is excellent and
typically fully correct, it's not always 100.0000...% correct.
Knowing how it actually implements things, and what is/was intended,
etc, can help in predicting what actually happens, or why things might
be slightly different than one might otherwise expect.
And similarly,
$ ls ... | sort
may give results different than, e.g. ls -1 or what one might
otherwise be expecting/anticipating,
e.g. in same directory again with same contents:
$ ls | sort
file
line
three
$