poniedziałek, 24 listopada 2008

oneliner: copy file that has searched phrase

Because my server history sometimes changes, I have to write down my favourite oneliner - which copy every file from some which contains searched phrase/word.
for i in `egrep -li 'searched phrase' *.eml`; do cp $i found/; done

if you just want to see those files, change cp to echo, like this
for i in `egrep -li 'searched phrase' *.eml`; do echo $i; done

but this one - is made just by:
egrep -li 'searched phrase' *.eml


0 komentarze: