管道 |

#千锋逆战班,云计算201#
在千锋“逆战”学习第 24 天,
我在千锋逆战班学习“云计算”今天学到了管道
学会了 | tee Xargs

闪电从不打在相同的地方,人不该被相同的方式伤害两次。

进程管道 Piping 管道命令可以将多条命令组合起来,一次性完成复杂的处理任务。
语法 command1 | command2 |command3 |…

案例:
at /etc/passwd | tail -3
ps aux | grep ‘sshd’

tee管道
简介 三通管道,即交给另一个程序处理。又保存一份副本

案例:
cat /etc/passwd |tee 88.txt | tail -1
qianfeng : x : 1001 : 1001 : : /home/qianfeng : /bin/bash
cat 888.txt 内容和tee 8.txt一样

参数传递 Xargs

cp rm一些特殊命令就是不服其他程序。
案例:
1 环境准备,准备一些文件。
touch /home/file{1…5}
ls /home
2 接到消息,部分文件需要删除。
vim files.txt
/home/file1
/home/file3
/home/file5
3 使用管道
cat files.txt |rm -rvf
失败
4 下面加上xargs
cat files.txt |xargs rm -rvf
removed ‘/home/file1’
removed ‘/home/file3’
removed ‘/home/file5’
ls /home
通过|xargs成功连接rm命令

你可能感兴趣的:(管道 |)