Wad*_* M. 33 linux bash copy find
任何人都有另一种在bash中查找和复制文件的方法:
find . -ctime -15 | awk '{print "cp " $1 " ../otherfolder/"}' | sh
Run Code Online (Sandbox Code Playgroud)
我喜欢这种方式,因为它是灵活的,因为我正在构建我的命令(可以通过任何命令)并在之后执行它.
是否有其他方法可以将命令简化为文件列表?
谢谢
asv*_*kau 81
我建议使用find的-exec选项:
find . -ctime 15 -exec cp {} ../otherfolder \;
与往常一样,请参阅联机帮助页以获得最佳结果.
您可以使用xargs:
$ find . -ctime 15 -print0 | xargs -0 -I{} cp {} ../otherfolder
Run Code Online (Sandbox Code Playgroud)
另请参见shell脚本中的grep实用程序。
| 归档时间: |
|
| 查看次数: |
63799 次 |
| 最近记录: |