Where is “showing the output of the ‘ls’ command vertically” documented?

I found out it’s possible to show the output of the ls command vertically using the -1 switch:

$ ls -1

But couldn’t find it in the manual of ls. Is it a secret option?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The manual is out of date with the program. Try ls --help | grep -- ' -1':

  -1                         list one file per line

It is one of the last options described if you just do ls --help.

Method 2

As @Timo indicates -1 is in the help, and @terdon points out the -1 is documented in the manual for some version. coreutils 8.13 has that error in the man page, version 8.22 doesn’t anymore.

In the hacking guidelines for coreutils. It is specified that

The man pages are generated from –help output, so
you shouldn’t need to change anything under man/.

So there must be something broken in the conversion causing the similar -m to show up but not the -1. While building ls with the patch I proposed in answer to @timo’s question, the manual page for ls gets regenerated correctly and the relevant part reads:

  -Z, --context
          print any security context of each file

  -1     list one file per line

  -0     list files separated with NUL

  --help display this help and exit

          output version information and exit

And without that patch, the -1 shows up in the manual as well. The git log shows no specific action to correct this. As recent as Sep 2013 help2man, which is used to generate the man pages, was updated. The help2man ChangeLog doesn’t show a specific action either.

Method 3

I suppose this will depend on your ls implementation but on my LMDE (basically Debian testing) I have:

$ man ls | grep -- '-1'
              across -x, commas -m, horizontal -x, long -l, single-column  -1,
       -1     list one file per line

As well as (yes, it’s the same output)
$ ls --help | grep -- '-1'
              across -x, commas -m, horizontal -x, long -l, single-column  -1,
       -1     list one file per line

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments