user172697
user172697

Reputation: 155

error /usr/local/bin/perl: Argument list too long

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*')

Upvotes: 1

Views: 1782

Answers (1)

Steve Weet
Steve Weet

Reputation: 28392

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.

Upvotes: 13

Related Questions