有没有办法告诉 bashfind
命令输出它在做什么(详细模式)?
例如对于命令:
find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
输出:
Found /media/1Tb/videos/102, executing rm -rf /media/1Tb/videos/102
...
Run Code Online (Sandbox Code Playgroud)
Ign*_*ams 73
你可以用 来编造一些东西-printf
,但最简单的就是-print
在最后加上。这将显示成功删除的内容。
Ham*_*sLi 20
仅rm -vf
用于详细 rm 输出如何。
$ touch file1 file2 file3
$ find . -name "file?" -exec rm -vf {} \;
removed `./file2'
removed `./file3'
removed `./file1'
Run Code Online (Sandbox Code Playgroud)
另一种方法是让命令执行sh -x
:
$ find . -type f -print0 | xargs -0 -n1 echo rm | sh -x
+ rm ./file1
+ rm ./file2
+ rm ./file3
Run Code Online (Sandbox Code Playgroud)