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 am (somehow) able to run a script:

$ assemble.sh file
... [output]

But which can't find it:

$ which assemble.sh
which: no assemble.sh 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 assemble.sh in your current directory? – Keith Mar 13 '11 at 20:54
Probably a dumb question, but is it an alias (i.e. does assemble.sh show up when you type the command alias ? – James McLeod Mar 13 '11 at 23:04
up vote 12 down vote accepted

Use this command: type assemble.sh

It works in a variety of shells and shows only the first result.

share|improve this answer
Or just type assemble.sh, 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
command -v assemble.sh


-v        print a description of COMMAND similar to the `type' builtin
share|improve this answer
Also would be useful if you want to find in a modified version of PATH ASSEMBLE=$(PATH=/usr/bin:/usr/local/opt/coreutils/libexec/gnubin command -v assemble.sh) – nhed Jul 15 at 15:36

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

find ${PATH//:/ } -maxdepth 1 -name assemble.sh -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
Didn't try but I guess this can break with spaces in components of PATH – nhed Jul 15 at 15:30

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

share|improve this answer
No, this shows the location of all (world-)readable files whose name contain assemble.sh, 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. assemble.sh 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.