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):
p.s. btw, depending on file contents grep might give unexpected results. e.g. grep 'rain' matches "grain".code:grep -lzir 'word' . | cpio --null -pvd /path/to/target-dir
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Copy files/folders with GREP
Ubuntu
Comments
Post a Comment