Find files containing a given string

If you want to find files containing a specificly given string and you want to remove those files, you should simply use this oneliner (Only searching for files in the current directory):


find . | xargs grep -l "STRING_TO_SEARCH_FOR" | awk '{print "rm -f "$1}' > && chmod u+x

After that, you only have to execute the script and the files containing the searched string will be removed. Attention: You should take a look at before executing it, just avoiding that files will be removed accidentally.


Das könnte Dich auch interessieren …

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Time limit is exhausted. Please reload the CAPTCHA.