Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My $PATH is set to a lot of directories including ~/bin and ~/target/bin

I want to execute script.sh which is in ~/target/bin but I get the error bash: ~/bin/script.sh: No such file or directory

This confuses me since which finds the correct directory ~/target/bin and ~/target/bin/script.sh executes fine.

Are there any special settings in bash that could lead to this wrong path handling?

share|improve this question

migrated from stackoverflow.com May 7 '13 at 10:19

This question came from our site for professional and enthusiast programmers.

Please post command line and PATH content. You might have better luck asking on Superuser. –  Stefano Sanfilippo May 7 '13 at 8:04
Does the script have execute permission? –  Barmar May 7 '13 at 8:16
@Barmar yes it has. As mentioned the script executes with full path –  Hachi May 7 '13 at 8:17

1 Answer 1

up vote 3 down vote accepted

You might try running hash -r to clear the executable cache.

Bash saves the location of the executable in a cache so it doesn't have to search the entire path again if you re-run the command. More on the hash command

share|improve this answer
that has helped; thank you very much. Could you please explain what this executable cache is? I've never heard of it before –  Hachi May 7 '13 at 8:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.