学习笔记
find命令 2
find /usr/ -name "*tmp" -exec ls -l {} \;
搜索到的结果去执行某个操作
{} 代表 find /usr/ -name "*tmp"部分 结果集放在{}中
;代表语句结束
\表示转义字符
1.转特殊
2.转本义 这里面转本义
-exec:将find的搜索的结果集执行某一指定命令
$find ./ -type f -exec ls -l {} \;
-rwxrwxrwx 1 root root 32151 Nov 29 00:53 ./dir1/stdio.h
-rwxrwxrwx 1 root root 154 Nov 29 00:38 ./dir1/file1
-rwxrwxrwx 2 1001 root 525 Nov 29 22:31 ./file1
-rwxrwxrwx 2 1001 root 525 Nov 29 22:31 ./file1.h
-rw-rw-r-- 1 ubuntu ubuntu 83 Nov 29 22:04 ./file2
-ok: 以交互式,将find的搜索的结果集执行某一指定命令
$find ./ -type f -ok rm -r {} \;
< rm ... ./dir1/stdio.h > ? no
< rm ... ./dir1/file1 > ? no
< rm ... ./file1 > ? no
< rm ... ./file1.h > ? no
< rm ... ./file2 > ? no
这篇博客介绍了如何利用find命令在Linux系统中搜索文件,并结合-exec或-ok选项对找到的文件执行特定操作,如删除。文章通过实例展示了如何在当前目录下查找所有以tmp结尾的文件,并分别使用-exec和-ok配合rm命令进行交互式或非交互式的删除操作。
7632

被折叠的 条评论
为什么被折叠?



