Linux查找当前目录下包含部分内容的文件,并且copy到指定路径的简单方法

1 获取文件列表

find . -name "*.data" |xargs  grep -i  'yearvariable' | uniq | awk '{print $1}' |cut -d : -f 1

2 将结果放置到一个txt 里面然后执行操作 注意 需要在当前目录下

for i in `cat 1.txt` ; do scp $i /root/20211008/ ; done

感觉还是比较简单的.

原文地址:https://www.cnblogs.com/jinanxiaolaohu/p/15382825.html