一、重定向(重新定向命令的输出)
1.简介
将前面命令的输出,作为内容,写入到后面的文件
>:覆盖重定向
>>:追加重定向
2.案例
[root@A /]# head -5 /etc/passwd > /opt/p.txt
[root@A /]# cat /opt/p.txt
[root@A /]# hostname
[root@A /]# hostname >> /opt/p.txt
[root@A /]# cat /opt/p.txt
[root@A /]# echo 123456
[root@A /]# echo 123456 > /opt/p.txt
[root@A /]# cat /opt/p.txt
[root@A /]# cat /etc/hostname
[root@A /]# echo 888888 > /etc/hostname
[root@A /]# cat /etc/hostname
二、管道(操作符号 | )
1.简介
ls ,rm,mv,cp不支持管道
作用:将前面命令的输出,传递给后面命令,作为后面命令的参数
2.案例
[root@A /]#head -4 /etc/passwd | tail -1
[root@A /]# head -8 /etc/passwd | tail -1
[root@A /]# cat -n /etc/passwd | head -8 | tail -1
[root@A /]# ifconfig | head -2
[root@A /]# head -12 /etc/passwd | tail -5
[root@A /]# head -12 /etc/passwd | tail -5 | cat -n
[root@A /]# cat -n /etc/passwd | head -12
[root@A /]# cat -n /etc/passwd | head -12 | tail -5
[root@A /]# cat -n /etc/passwd | head -12 | tail -5 > /opt/pa.txt
[root@A /]# cat /opt/pa.txt