I'm trying to run some simple bash script which uses wc and cat commands. The script fails with this:
wc: command not foundor this (after I commented string which uses wc):
cat: command not foundI have no idea what's going on. A similar script which contains exactly the same fragments of code works just perfect. Both scripts are used in the same conditions. Besides,
machine:~ user$ which wc
/usr/bin/wcand
machine:~ user$ which cat
/bin/cat 2 1 Answer
As pointed out by @Tyson, the PATH variable holds the answer.
I just wanted to point out that using full paths in your scripts is usually considered a good practice. For example, instead of calling wc you might want to call /usr/bin/wc. Besides resolving the above problem, it's more secure, as you prevent running an application that someone might have put in your PATH using the same name... I can't remember the name of those attacks, but you get the idea =)