Linux shell find exec使用案例

内容分享2小时前发布
0 0 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]$

© 版权声明

相关文章

暂无评论

none
暂无评论...