bash - `rm -f` 要求确认,别名为 `rm -i`

标签 bash alias rm

我正在使用此命令尝试删除一个非常大的文件夹中的所有 Thumbs.db 文件。我认为 -f 应该在不要求确认的情况下强制删除,但我仍然被提示在每个文件上输入“y”或“n”。

find "megapacks" -name Thumbs.db -ok rm -f {} \;

我尝试键入 rm 来查看是否有别名,它的响应是

rm is aliased to `rm -i'

我尝试使用 /bin/rm 代替,但仍然提示我

find "megapacks" -name Thumbs.db -ok /bin/rm -f {} \;

有没有人对如何避免确认有其他想法?

最佳答案

问题出在 -ok 选项上,根据 man find:

Like -exec but ask the user first. If the user agrees, run the command. Otherwise just return false.

这应该适用于 -exec:

find "megapacks" -name Thumbs.db -exec /bin/rm -f {} \;

或更快:

find "megapacks" -name Thumbs.db -exec /bin/rm -f {} +

关于bash - `rm -f` 要求确认,别名为 `rm -i`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38719531/

相关文章:

linux - 创建动态别名,是否可能?

terminal - 如何从终端递归删除特定名称的文件

python 或 bash - 在行尾添加 "at beginning of line and "

bash - 如何在awk中转义gsub中的 "["?

MySQL查询对CASE WHEN公式的极慢过滤

Linux 脚本无法通过 crontab 删除文件,但它可以手动工作

linux - 如何在 Linux 上的 Bash 中一次删除多个文件?

linux - 脚本 bash chmod 绕一圈

linux - 将关联数组作为 Bash 的参数传递

bash - OhMyZsh : override Git plugin aliases with custom multi-line aliases/functions