I want to delete all files that contain the string
foo. How can I do this using bash in Linux?
Here is a safe way:
If you would like to see which files are about to be deleted, simply remove the
Another user suggested something like the following, which you should not run because it is unsafe:
If I have files
This recursively searches for files containing
as suggested by Lekensteyn.
I'd do what Adrian says,
But I'd add word boundries arond the foo so as to not accidentaly delete files containing "food" (unless it is deleting everything containing food is what you want.)
acutally, I'd redirect the output before deleteing so I could review before deleting: