Quantcast
Channel: On Linux, how can I find all files that contain a string and delete them? - Super User
Browsing all 4 articles
Browse latest View live

Answer by Petter H for On Linux, how can I find all files that contain a...

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.) $ find...

View Article



Answer by Lekensteyn for On Linux, how can I find all files that contain a...

Here is a safe way:grep -lrIZ foo . | xargs -0 rm -f ---l prints file names of files matching the search pattern.-r performs a recursive search for the pattern foo in the given directory .. If this...

View Article

Answer by Adrian Frühwirth for On Linux, how can I find all files that...

$ find -type f -exec grep -q "foo" {} \; -exec echo rm -- {} \;This recursively searches for files containing foo. The second -exec is only run if the first exec exits successfully, i.e. if grep...

View Article

On Linux, how can I find all files that contain a string and delete them?

I want to delete all files that contain the string foo. How can I do this using bash in Linux?

View Article
Browsing all 4 articles
Browse latest View live




Latest Images