美文网首页
Linux shell find exec使用案例

Linux shell find exec使用案例

作者: A04 | 来源:发表于2022-08-30 09:35 被阅读0次

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

相关文章

网友评论

      本文标题:Linux shell find exec使用案例

      本文链接:https://www.haomeiwen.com/subject/yurlnrtx.html