Search code examples
linuxls

Why does ls -x not produce one entry per line per the man page documentation?


I am trying to feed the results of ls into a Perl script. The man page for ls indicates that using the -x switch, ls should output one entry per line. However, it would seem that ls and ls -x produce exactly the same output. Now if I do ls -1, I get the desired output. So, what does the -x switch actually do?


Solution

  • I don't know where you read that -x lists one file per line, but that is wrong. The man page says -x lists files by lines instead of by columns (i.e. two consecutive files will be displayed in two consecutive lines instead of two consecutive columns).

    The option you're looking for is -1.