Linux shell find exec使用案例

内容分享2个月前发布
1 0 0
全能 AI 聚合平台 免费

一站式接入主流 AI 大模型,支持对话 · 生图 · 生视频,即开即用

ChatGPT Claude Gemini Grok DeepSeek 通义千问 Ollama
AI对话 AI生图 AI视频
免费使用 →

  
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
暂无评论...