如何使用 ack-grep (ag) 删除包含特定字符串的所有文件
基于我们之前的文章如何使用 ack-grep (ag) 列出包含特定字符串的文件名,此示例展示如何删除当前目录中包含字符串 403 Forbidden 的所有文件。
例如,为了列出包含字符串 403 Forbidden 的文件名,使用
ag -0 -l “403 Forbidden” | xargs -0 rm -v
ag_delete_files.sh
ag -0 -l "403 Forbidden" | xargs -0 rm -v使用 ag -0 是正确处理包含空格的文件名所必需的。
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow