0

In the man pages it says:

-C     list entries by columns

However, I really cannot notice any difference between the output of ls or ls -C, could someone explain this to me?

  • 2
    Try piping ls to some command, like cat or tail. – muru Feb 15 '15 at 18:40
  • @muru Show the difference but there is no difference when it prints directly to stdout so why such a functionality is needed? – Vesnog Feb 15 '15 at 18:43
  • maybe to save ls's output to something but preserve how it actually appears. Or process it for some reasons but still show a nice form to the user.. Who knows? It's specified by POSIX, so if anyone has access to their discussions, we might know. – muru Feb 15 '15 at 18:46
  • That's because -C is the default in this scenario. The option is turned on, whether you specify it or not. – Ned64 Jun 5 '15 at 9:21
2

To add what @muru said in the comments; have a look at info coreutils ls

`-C'
`--format=vertical'
     List files in columns, sorted vertically.  This is the default for
     `ls' if standard output is a terminal.  It is always the default
     for the `dir' program.  GNU `ls' uses variable width columns to
     display as many files as possible in the fewest lines.

I take this to mean -C exists specifically for the case where you redirect or pipe the output and want to preserve columnation. Otherwise ls will switch to ls -1 when it detects that it's not displaying to a terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.