有没有办法在find . -exec somecommand {} \;
不实际运行命令的情况下查看替换的结果?像试运行(或试运行或打印)?
例如,假设我有以下文件结构:
/a/1.txt
/a/2.txt
/a/b/3.txt
Run Code Online (Sandbox Code Playgroud)
有没有办法find . type f -exec rm {} \;
从a
目录中进行测试,以便输出将打印到 stdout 但不执行,例如:
rm 1.txt
rm 2.txt
rm b/3.txt
Run Code Online (Sandbox Code Playgroud)
更新
说明:rm
只是一个示例命令,我对一般情况感兴趣
rAl*_*len 18
你可以运行echo rm
而不是rm
find . type f -exec echo rm {} \;
Run Code Online (Sandbox Code Playgroud)
此外,find
可以-delete
选择删除它找到的文件