[prog] echoing something to STDERR

Hamster hamster at hamsternet.org
Tue Nov 11 22:14:39 EST 2003


Hi,

I'm writing a bash script, in which part of it tests for the existence of a
particular file.

What I'd like to do, is if the file doesnt exist, I want to it to print an
error message on STDERR.

Something like:

[ -f foo.txt ] || echo "foo.txt doesnt exist" 

The problem with this is that echo plonks stuff on STDOUT, I want it to go
to STDERR.

How do I do that?

Thanks! :-)

Hamster


More information about the Programming mailing list