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]$

推荐阅读更多精彩内容