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

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/
| improve this answer | |
  • ... this work with me . thanks for your help & for the simplified explanation. – user3716621 Oct 31 '15 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.