This question already has an answer here:

In brief: ls -a /tmp works but ls /tmp -a does not.

I recently started using Macbook Pro. Coming from a Linux background, command like ls /tmp -a seems perfectly fine to me.

But for some reason these do not work in the same fashion in Mac. Argument flags are not recognised if they are specified at the end after the path.

Here is a demo:

/tmp/demo  ➜ ls -a ./
.           ..          .hidden-bar foo
/tmp/demo  ➜ ls ./ -a
ls: -a: No such file or directory
/tmp/demo  ➜     

I am using latest zsh 5.0.5 (x86_64-apple-darwin14.0)

I can see similar behaviour of several other commands like du, rm etc. Almost all such are in /bin folder. I wonder if it has something to do with UNIX and Linux differences.

Does anybody know the reason behind the difference and if possible a fix for it?

marked as duplicate by nohillside Apr 3 '15 at 21:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your original question/statement mentions arguments but you're actually asking about placing options at the end of a command line ;-) – ScunnerDarkly Apr 2 '15 at 10:07
  • OSX was spawned off of, I think, FreeBSD, while Linux uses GNU tools. I'm surprised that GNU tools allow options to follow arguments. I'd recommend you retrain your brain and get used to the BSD fashion. – glenn jackman Apr 2 '15 at 10:34

This is because apple zsh shell version. To install zsh version with that behaviour, you have to install homebrew. You can easily to it by typing the following:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once installed, install the zsh formulae:

brew install zsh

Then you have to replace your shell with zsh provided by homebrew:

chsh -s /usr/local/bin/zsh

After that you should be able to test your zsh version and use command arguments like you want.

Not the answer you're looking for? Browse other questions tagged .