Linux shell find exec使用案例

  
find命令之exec
-exec参数后面跟的是command命令,它是以 ; 为结束标志,由于各个系统中分号会有不同的意义,因此在前面加上反斜杠
{} 代表前面find查找出来的文件名
【参考来源:linux find之exec用法Dannii的博客-CSDN博客 https://blog.csdn.net/qq_36748278/article/details/83029484

[test@test home]$ cd historylog/
[test@test historylog]$ ls
202208
[test@test historylog]$ vi test

~
"test" [New] 1L, 2C written                                                                                                                                                                                                
[test@test historylog]$ ls
202208  test
[test@test historylog]$ find /home/historylog/  -name test
/home/historylog/test
[test@test historylog]$ find /home/historylog/  -name test -exec ls \;
202208  test
[test@test historylog]$ find /home/historylog/  -name test -exec mv {} /home/historylog/202208/ \;
[test@test historylog]$ ls
202208
[test@test historylog]$ ls 202208/
test
[test@test historylog]$
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容