Take the 2-minute tour ×
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:

$ 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
1  
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
add comment

5 Answers

up vote 12 down vote accepted

For bash use type -a assemble.sh

share|improve this answer
8  
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
add comment

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
add comment

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 –  Shurane Jan 10 '13 at 8:33
add comment

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
add comment
command -v assemble.sh

Info

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

Your Answer

 
discard

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.