Skip to main content

Thread: Copy files/folders with GREP


i'm attempting find particular word wherever appears within massive directory listing of teeny tiny text files -- , copy files containing word "staging" directory.

whenever use command below (on test folder of smaller scale), never carries directory structure attempts copy files within "output" folder.
code:
cp `grep -ir 'word' *` output

on how copy these text files , have them retain sort of directory structure?


thanks,
chris

try along lines of (from folder want copy):

code:
grep -lzir 'word' . | cpio --null -pvd /path/to/target-dir
p.s. btw, depending on file contents grep might give unexpected results. e.g. grep 'rain' matches "grain".


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Copy files/folders with GREP


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support