1

Why doesn't ls behave the same after exchanging the order of options -l and -f?

$ ls -l -f
0821131236.jpg   0823130821.jpg

$ ls -f -l
total 33176
-rw-rw-r--  1 t    t    364186 Jan  6 16:06 0821131236.jpg
-rw-rw-r--  1 t    t    170003 Jan  6 16:06 0823130821.jpg

What advice should I follow when running ls or other utilities/commands with several options?

1
  • -f -l supersede the behavior Commented Feb 10, 2016 at 7:47

2 Answers 2

5

This is a documented behavior.

From info ls:

-f:

 Primarily, like `-U'--do not sort; list the files in whatever
 order they are stored in the directory.  But also enable `-a' (list
 all files) and disable `-l', `--color', and `-s' (if they were
 specified before the `-f').

What you should use totally depends on what you need.

5

In a typical software, the arguments are usually processed in order, so a latter option gets to overwrite the former ones if they are in conflict, but still enabled to be used together. But this is just a general rule of thumb. You have to check the documentation of the particular software you intend to use and try it out for yourself.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.