unix - SSH command to find and delete all files that contain a string -


i need use ssh find files containing string (malware) , delete these files.

this command using find , display list of these malware files:

find * -name '*.php' -exec grep -l "return base64_decode(" {} \; 

and list this:

enter image description here

i want delete these files (not display list of them).

basically "find files contain string, , delete files".

you can pipe xargs rm given file names removed:

find * -name '*.php' -exec grep -l "return base64_decode(" {} \; | xargs rm 

you can store current output of find , loop through content executing rm <file>:

find ... > file while ifs= read -r file     rm "$file" done < file 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -