How can a linux command script print warnings or error messages without using >/dev/stderr
each time?
This should be simple but I don't get it.
Can you post a simple example?
How can a linux command script print warnings or error messages without using >/dev/stderr
each time?
This should be simple but I don't get it.
Can you post a simple example?
To print to standard error, use a command that writes to standard output (like
echo
orprintf
) and redirect the output to file descriptor 2.This is the most common use of the file descriptor duplication operator, which makes the descriptor indicated by the preceding number (or 1 if omitted) a copy of the descriptor indicated by the following number.
Every unix process always has three open file descriptors when the process starts.
0 is stdin
1 is stdout
2 is stderr
http://man7.org/linux/man-pages/man3/stdout.3.html