See the manpage for ls
, namely the flag -1
:
-1 (The numeric digit ``one''.) Force output to be one entry per line. This is the default when output is not to a terminal.
If you want to force multi-column output use
-C Force multi-column output; this is the default when output is to a terminal.
So to answer your question, yes, ls
is aware where the output goes and it has well-defined behavior depending on it which you can easily override.