wc / cat command not found

I'm trying to run some simple bash script which uses wc and cat commands. The script fails with this:

wc: command not found

or this (after I commented string which uses wc):

cat: command not found

I 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/wc

and

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 =)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like