[Posts] the Linux Guide (12) - linux input and output redirection

Linux Tutorials (12) - linux input and output redirection

Disclaimer: This article is a blogger original article, follow the  CC 4.0 BY-SA  copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_42350428/article/details/81916112

Input and output redirection 
command> file // standard output redirected to a file - covering 
command >> file // standard output redirected to a file - Append 
Write pictures described here 
command 2> // standard error redirected to file - covering 
Command 2 >> // standard error is redirected to a file - append 
Write pictures described here 
command 2> / dev / null // redirect standard error to the Recycle Bin 
Write pictures described here 
command &> file // standard output and standard error redirected to file - covering 
Write pictures described here 
command >> file 2> & 1 // standard output and standard error redirected to file - append 
Write pictures described here 
Write pictures described here 
Write pictures described here 
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 
Write pictures described here 
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

Write pictures described here

 

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11858025.html
Recommended