2> is input redirection symbol and syntax is:
- To redirect stderr (standard error) to a file:
command 2> errors.txt - To redirect both stderr and stdout (standard output):
command &> output.txt
How to redirect standard error in bash
Run find command and save all error messages to the find.error.txt file:
find / -name "*.conf" 2> find.error.txt
You can view find.error.txt with the cat command:
cat find.error.txt
This is useful in shell scripts or any other purpose.
How to redirect standard error and standard output in bash
You can send both stdout and stderr to a file named output.txt
command &>output.xt
find / -name "*.pl" &>filelist.txt
Please note that both errors and the actual output of the find command stored into a file:
cat filelist.txt