点击这里给我发消息QQ客服

Linux 基础系统符号 | 竖线符号

云之渝 2021-11-05

| 竖线符号 (管道符号)


1. 表示管道符号,管道前面的命令交给后面执行



2. 经常配合xargs命令使用


find /opt -type f -name "*.txt"  -delete

find /opt -type f -name "*.txt"  -exec rm -rf {} \;

find /opt -type f -name "*.txt"  | xargs rm -rf


echo  ddd{01..10}

echo  ddd{01..10} | xarges -n1


查找指定数据进行复制


find /opt -type f -name "*.txt" | xargs cp /opt/backup

imgclip.png

#添加 -i  {} 参数  让前面的结果 放到{} 里面

#将找到的信息放到cp 和最终目录中间

find /opt -type f -name "*.txt" | xargs -i cp {} /opt/backup/


imgclip_1.png

#-t  target

#利用cp指明数据最终保存目录信息

find /opt -type f -name "*.txt" | xargs cp -t /opt/backup

imgclip_2.png


exec方法

find /opt -type f -name "*.txt" -exec cp -a {} /opt/backup \;

imgclip_3.png


其他命令 如 MV  类似