Redirection is very common and useful in Linux.
- stdout – Normal messages output displayed on terminal after running a command
- stderr – Error messages displayed on terminal after running a command
Here are some examples for manipulate the stdout and stderr.
Redirect stdout to a file
- cat <file> > result.txt
Redirect stderr to a file
- cat <file> 2> result.txt
Redirect stderr to stdout (Show both stdout and stderr on terminal)
- cat <file> 2>&1
Redirect the stderr and stdout to a file
- cat <file> &> result.txt
Silence both the stdout and stderr
- cat <file> &> /dev/null
Done =)
Reference: All about redirection
Useful, thank you!
LikeLike
you are welcome =)
LikeLike
can i manipulate standard error befor appending it to some file ?
LikeLike
Maybe sed could help.
Text Manipulation with sed
LikeLike