On my macOS machine, I noticed that sometimes the which command returns paths with two consecutive slashes. For example:

bash-3.2$ which gcc
bash-3.2$ which qr

However, for some programs which returns normal paths.

bash-3.2$ which bash
bash-3.2$ which which

I tried these commands in both bash and zsh, and their outcomes are the same.
I have never seen this in Linux systems, what is the reason for the two consecutive slashes?

  • What does echo $PATH show ?
    – mmmmmm
    Oct 26, 2021 at 10:49
  • I checked the PATH variable and found some paths have the trailing slash and some do not. After removing the trailing slash the outputs become normal. Thank you @mmmmmm!
    – Jerry Wang
    Oct 26, 2021 at 11:01

1 Answer 1


It looks like that you need to make the directories in $PATH not have a trailing /

ie you has /usr/local/bin/ in your path and it should be /usr/local/bin

You must log in to answer this question.

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