Linux Tutorials (12) - linux input and output redirection
Input and output redirection
command> file // standard output redirected to a file - covering
command >> file // standard output redirected to a file - Append
command 2> // standard error redirected to file - covering
Command 2 >> // standard error is redirected to a file - append
command 2> / dev / null // redirect standard error to the Recycle Bin
command &> file // standard output and standard error redirected to file - covering
command >> file 2> & 1 // standard output and standard error redirected to file - append
such as
[root @ localhost tmp] # DATE> abc
[root @ localhost tmp] # DATE >> abc
[root @ localhost tmp] # CAT / etc / passwd> abc
[root@localhost tmp]# 1234 2> abc
[root@localhost tmp]# 1234 2> /dev/null
[root@localhost tmp]# 1234 >> abc 2>&1
With scheduled tasks
/ 1 * * * DATE >> / tmp / abc
character: |. This is the pipe character.
Two acts:
1, nexus: the input on the output as an instruction to execute an instruction.
2, with grep character to achieve filtering.
[root@localhost tmp]# ls -l /etc/ | more
[root@localhost tmp]# ps -aux | grep cron
[root@localhost tmp]# ps -aux | grep cron > abc