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:
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
Post a Comment