Remove files, which provided by pipe
14,724
Although you can probably do this whole thing with find command only you can try appending |xargs rm -f
to that command.
Here's what it would look like
find . -print | grep php | xargs grep 'eval' -sl | \
xargs wc -l | grep ' [1-2][0-9] ' | \
cut -f 2 -d ' ' | xargs rm -f
Note that the xargs rm
command works here because you know there aren't any special characters in the file names. If there might be spaces in the file names, you can use xargs -d '\n' rm -f
(Linux only).
Related videos on Youtube
Author by
Roland Soós
Updated on September 17, 2022Comments
-
Roland Soós over 1 year
I have this command chain:
find . -print | grep php | xargs grep 'eval' -sl | xargs wc -l | grep ' [1-2][0-9] '
This provide me this output:
14 ./includes/js/calendar/lang/vgju.php 18 ./includes/phpInputFilter/default.php 14 ./includes/Archive/eula.php 18 ./media/system/js/json.php
This files are infected php files and I would like to remove it with my chain. How can I do it?
-
Roland Soós over 13 yearsThis wont work, because there is the line numbers in the output of my command. Is there some substring command wherewith I could split the lines after the line number?
-
Shawn J. Goff over 13 years@Roland add cut -f2 -d' ' to the pipeline right before the suggested xargs
-
Luis over 13 yearstry xargs -n1 rm -f
-
Roland Soós over 13 yearsThanks for both of your. Luis solution worked. Now I get the full list with this funny command: find . -print | grep php | xargs grep 'eval' -sl | xargs wc -l | grep ' [1-2][0-9] ' | xargs -n1 | grep 'php'