小编opt*_*lic的帖子

为什么从 Bash 历史记录中删除条目时会出现错误?

我的 Bash 历史记录中有一些我想删除的命令。

我可以找到它们history | grep "command with password"然后删除它们history -d <line-number>

但是,当我尝试通过管道将它们批量删除时,xargs我收到一个错误:

history | grep "command with password" | awk '{print $1}' | sort -r | xargs history -d
xargs: history: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我认为这xargs会遍历行号列表并将其一一发送给history -d命令。

是什么导致了这个错误?

注意:我知道还有其他方法可以删除历史记录,问题纯粹是为了提高我对xargs工作原理以及导致错误的错误的理解。

bash command-history xargs

8
推荐指数
1
解决办法
827
查看次数

标签 统计

bash ×1

command-history ×1

xargs ×1