30

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?

  • 1
    man ls does tell: -1 list one file per line. Info pages usually contain more information, try info ls. – devnull Feb 1 '14 at 9:11
33

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.

  • /bin/ls also gives output in columns, at least it does on my system. What is your ls aliased to? – terdon Feb 1 '14 at 19:17
  • Recent addition? OK, it's not in V7. But 2BSD had it. The oldest GNU version I can find right now, fileutils 3.12 had it, including documentation in the man page, and the ChangeLog goes back to version 1.0 in 1990 with no mention of it being added as a new option. I think it's always been there. – user41515 Feb 1 '14 at 20:22
  • @timo, Thanks for the answer. Nice way to Explanation. Works for me. – AMIC MING Apr 10 at 15:13
6

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

  --version
          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.

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
  • OS X man page for ls also shows the -1 option. – Arne Feb 1 '14 at 19:40
  • This seems to have been fixed. coreutils 8.13 has that error in the man page, version 8.22 doesn't. – Anthon Feb 3 '14 at 14:15

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.