My $PATH is set to a lot of directories including
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?
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