I have two environments: Mac and Linux.

I wonder about the command:

it can show just 2 lines of text if I invoke it like so:

vim --version | head -2

I saw this online and ran to the page to learn more only to discover that neither the nor the pages have any information that I could decipher describing the possibility of using -2 directly to get just 2 lines of text from .

So my questions are:

  • am I reading the man pages wrong?
  • if so, what indicates the possibility of specifying -2 directly?
  • if not, is it common for recognised options not to be explicitly outlined in the page?
  • if not in , where should I look for full disclosure on a command's options?
  • are there many other convenient features like this, which objectively make much nicer and direct to use, that I am oblivious to and can't learn about by studying -h output and/or a page?


OS X v10.8.3 (build 12D78)


GNU/Linux (kernel 3.5.0-25-generic) Ubuntu 12.10

GNU coreutils 8.12.197-032bb

  • 1
    Hiya, am not sure I'm understanding your question clearly. If you have ten lines of stdin text and pipe it to head i.e. # cat somefile.txt | head -n 2 It should spit out the first two lines of somefile.txt (btw, -2 may work, but -n is the actual argument to specify the number of lines, while -c specifies the number of bytes.)
    – Stephan
    Apr 2, 2013 at 21:17
  • 1
    head -2 is synonym to head -n 2, why? Where does it say so in the manual? head -3 is synonym to head -n 3, etc. This being the case but not being explicitly documented has a feel of "black magic"/"secret lore".. ;) Apr 2, 2013 at 21:18
  • At least you'll get the full disclosure by reading the source, Luke.
    – ott--
    Apr 2, 2013 at 21:21
  • And by doing so, succumb to the hopelessness of the dev/user divide, plunging into a life of pessimism and psycho-active tablets. There must be hope beyond browsing the source! Apr 2, 2013 at 21:22

1 Answer 1


Essentially, you've found the backwards compatibility flags (which, to be honest, I had never known existed.)

From the man page:

       The  full documentation for head is maintained as a Texinfo manual.  If the info and head programs
       are properly installed at your site, the command

              info coreutils 'head invocation'

At the bottom of the info coreutils page:

For compatibility `head' also supports an obsolete option syntax
`-COUNTOPTIONS', which is recognized only if it is specified first.
COUNT is a decimal number optionally followed by a size letter (`b',
`k', `m') as in `-c', or `l' to mean count by lines, or other option
letters (`cqv').  Scripts intended for standard hosts should use `-c
COUNT' or `-n COUNT' instead.  If your script must also run on hosts
that support only the obsolete syntax, it is usually simpler to avoid
`head', e.g., by using `sed 5q' instead of `head -5'.

An exit status of zero indicates success, and a nonzero value indicates failure.
  • 1
    So the answer to one of the points above is: sometimes look into the info of the command after reading the --help and man.. Apr 2, 2013 at 21:37
  • yep; especially if the bottom of the man page suggests it ;)
    – Stephan
    Apr 2, 2013 at 21:40
  • I guess another point to learn is: some options fall out of fashion, get deprecated and are actively hidden/deprecated so that new users (like me) will avoid them. You know what I think would be better than this hiding (not putting in plain sight) approach? Just show the option and say: don't use this - it may not be there in a future version. I would have been less confused. Probably just me though. Apr 2, 2013 at 21:47
  • Thanks for answering my question, you also taught me some more in the process, I appreciate it. Apr 2, 2013 at 21:48

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.