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

Using ag -0 is neccessary to handle filenames containing spaces correctly.