Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 have an executable script test under the full path /home/sawa/foo/bar/test. The directory /home/sawa/foo/bar is within $PATH, and has priority over the default ones including /usr/bin. When I do

`which test`

to see whether this command is correctly recognized, it returns


with the double slash //. I know that there is a built in command with the same name test, and when I remove mine, this one under /usr/bin/test is returned by which, so I think it's interfering in some way.

  1. What does this double slash mean here, and why is it appearing here?
  2. My executable test does not seem to work correctly. Why is that?
share|improve this question
up vote 7 down vote accepted

I would guess that you have /home/sawa/foo/bar/ on your path - i.e. a path with a trailing slash.

which is iterating over each element of $PATH and appending /argv[1] and checking for the existence of that file. That causes a double-slash - one from the $PATH part, and one from /argv[1].

A double-slash is no problem. It is collapsed to a single slash by the kernel. Only at the beginning of a path may a double-slash have special meaning, and not always then.

As for test not working, ensure you are not using the shell built-in when calling test. You usually do this by using a full path, but with bash you can also use enable -n test to disable the built-in test command.

share|improve this answer
Thanks. That's the perfect answer that I wanted. It helps. – sawa May 3 '11 at 15:18

Most likely it doesn't work for you because the shell builtin is getting executed with priority over any executable. You should not knowingly create a name conflict like this, behavior will be inconsistent across environments. The system binary test is only there for the use of shells that don't have a builtin version.

If you want alternate functionality, you should name your script something else.

share|improve this answer
That advice given, I don't actually know what // represents here so it will be interesting to hear from somebody who does :) – Caleb May 3 '11 at 8:58
Thanks for the information regarding the priority. – sawa May 3 '11 at 15:18

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.