0

i have many php files maybe over Three million..
how can i use grep with xargs and find with mv to find contain the string in files and move them to directory if they match.

I try like that

find . -iname \*.php\* | xargs -n64 grep -hEl 'to times' | xargs -0 -I {} mv {} old/

that doesn't do anything.

but if i run without the second xargs i got result like this...right files

./20150713094500*/vb/showthread.php?p=10297131
./20150715080347*/vb/showthread.php?t=1133875&page=3
./20150630233104*/vb/member.php?find=lastposter&t=1234502

1 Answer 1

1

Find files that matches '*.php*

find . -type f -name '*.php*' |

then pass each file name to grep which will output only file names if 'to times' string wil be found

xargs -I {} grep -l 'to times' '{}' |

then pass each file name to mv

xargs -I {} mv '{}' old/
1
  • ... this work with me . thanks for your help & for the simplified explanation. Oct 31, 2015 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .