views:

67

answers:

1

Hello guys ive executed this command to delete malwarm from all my websites files and keep backup from each files but after 1 mint from executing got error /usr/local/bin/perl: Argument list too long

Can anyone suggest a way to avoid this error , PS ive a huge a mount of files :)

 perl -e "s/<script.*PaBUTyjaZYg.*script>//g;" -pi.save $(find /home/ -type f -name '*php*')
+9  A: 

Use the xargs command which reads file names from STDIN and runs the command multiple times passing as many filenames as it can to each invocation of the target command

find /home/ -type f -name '*php*' -print0 | xargs -0 perl -e "s/<script.*PaBUTyjaZYg.*script>//g;"

The print0 argument to find works with the -0 argument to xargs to ensure that file names are terminated with a null character. This prevents filenames with embedded spaces from causing an error.

Steve Weet
xargs even has an -n command to control the number of arguments it will pass per invocation, something I occasionally need.
reinierpost
Steve , perfect , thanks alot , another tip please now i need to delete all files ended with *.php.save
xargs is just building a command list for you so you just need to do the find and pass it to xargs rm so something like this `find /home/ -type f -name '*.php.save' -print0 |xargs -0 rm`
Steve Weet
great , and what if i want to delete all files has numbers in thier name and extension .php how to perform this ?
Well you're just building find commands and passing them to xargs so check out the man page for find but this should find all files with numbers in the name and a .php extension `find /home/ -type f -name '*[0-9]*.php`
Steve Weet