Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am (somehow) able to run a script:

$ file
... [output]

But which can't find it:

$ which
which: no in (/s/std/bin:/usr/afsws/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/ucb:/bin:/usr/bin:/usr/stat/bin:/usr/X11R6/bin:.
  1. How is this possible?
  2. How can I find where this file is?

I'm using bash.

share|improve this question
Is in your current directory? – Keith Mar 13 '11 at 20:54
Probably a dumb question, but is it an alias (i.e. does show up when you type the command alias ? – James McLeod Mar 13 '11 at 23:04

5 Answers 5

up vote 12 down vote accepted

For bash use type -a

share|improve this answer
Or just type, which is portable (and only shows the first match whereas type -a is a ksh/bash construct to show all matches). – Gilles Mar 13 '11 at 22:24

You may be using bash, but the syntax of the which output shows that you use the old which written in csh. The PATH shows up quoted by parentheses, and the directories in PATH have entries like /opt/SUNWspro/bin and /usr/ccs/bin which only make sense in Solaris. That's consistent: Solaris used the csh which.

Here's my guess: you've got one PATH for bash, and another for csh. This might be a system problem. As I recall, Solaris keeps /etc/profile and /etc/cshrc files for system-wide PATH setting. Those two initialization files might set different PATH variables for different shells. Do "echo $PATH" under bash, and see if it agrees with what the which command prints out as a PATH string.

share|improve this answer

Or split the path, and use it in find - the first match should be the solution

find ${PATH//:/ } -maxdepth 1 -name -print -quit

type is of course more easy.

share|improve this answer
This is fairly useful. I didn't know I could split $PATH into its sub components and search each one with find – Ehtesh Choudhury Jan 10 '13 at 8:33
command -v


-v        print a description of COMMAND similar to the `type' builtin
share|improve this answer

You can use locate to find the location of the file.

share|improve this answer
No, this shows the location of all (world-)readable files whose name contain, which is irrelevant here. – Gilles Mar 13 '11 at 22:22
It is not irrelevant at all. Even if he had multiple files called like that locate would also give him the location of the one he wants. is not such a common filename, so he will likely find the file easily (which is what the OP requests). – nico Mar 13 '11 at 22:50
Don't you have to updatedb before locate shows results? – glenn jackman Mar 14 '11 at 0:02
Usually updatedb is run daily as a cron job, but yeah, you may have to force it if the file is very recent. – nico Mar 14 '11 at 0:15

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.