Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just starting using a Mac and have been frustrated that command line options are required immediately following the command so that this works:

ls -la /usr

but this doesn't:

ls /usr -la

ls: -la: No such file or directory

Is there any way to change this? Or can someone tell me why the placement of options is agnostic on most Linux platforms, but not on Mac?

share|improve this question

migrated from May 9 '10 at 21:50

This question came from our site for professional and enthusiast programmers.

It varies in Linux, and probably has to do with whether a particular command uses the GNU "getargs". In this example, "ls" indeed will work with an option parameter after a file or directory name. – Pointy May 9 '10 at 12:46

Linux uses GNU tools. OS X uses BSD tools. BSD tools are far more picky about order and presence of command line arguments.

share|improve this answer

Command line processing is determined in a source code of the program that became a specific command.

More often than not, a bunch of commands use a specific command line processing library (GNU getargs, or in case of Perl scripts GetOpts::Long are examples of such), though whether the command line processing was hand-rolled or used any specific library is entirely dependent on the command.

Therefore the abilities of command line processing (e.g. support for reordering, use of -- to delineate end of flags, folding of -a -b into -ab, etc...) depend entirely on the source code of individual apps and/or the libraries they use.

The specific pattern you noted is probably due to differing command line processing libraries (or individual hand-rolled arg processing code used by developers) between Linux with its GNU roots and OSX (IIRC, BSD origins but not sure)

share|improve this answer

The reasons is likely in the command line processing libraries but if I had to guess the motivation of the strict ordering libraries it is to impose consistency. First named parameters then positional parameters. Once consistency is imposed it makes command lines easier to parse mentally.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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