How to delete all files containing a specific string using ack-grep (ag)
Based on our previous post How to list filenames containing a specific string using ack-grep (ag) this example shows how to delete all files in the current directory containing the string 403 Forbidden.
For example, in order to list filenames containing the string 403 Forbidden, use
ag -0 -l “403 Forbidden” | xargs -0 rm -v
ag_delete_files.sh
ag -0 -l "403 Forbidden" | xargs -0 rm -vUsing ag -0 is neccessary to handle filenames containing spaces correctly.
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