Help - Search - Members - Calendar
Full Version: Help appriciated, grep/mv
The Planet Forums > Operating Systems > Red Hat Linux
aventure
Scenario
Folder 1 containing around 500 files
Folder 2 for filtered material

The idea: grep all files in Folder 1 for say "cookie" and mv all files containing "cookie" into Folder 2

public_html/Folder1
public_html/Folder2

I've tried everything I can find online such as
grep -l "cookie" searchfiles | xargs -n1 {} mv "{}" /Folder2

mv `grep -lr 'cookie' /Folder1` /Folder2

But nothing, anyone icon_biggrin.gif ?
EV1-DanielC
grep -l "rm" * > list; echo "while(){ chomp($_);system("mv $_ dir2");}"> run;cat list|perl run

grep for "rm" move that to a list... then make a perl script, cat list to it, and it moves it to "dir2"
EV1-DanielC
not perfect, or effecient, but works.

mv `grep -l "rm" *` dir2

is better.

(only if you're in the directory)


so:
mv `grep -l "rm" dir1/*` dir2
aventure
Cheers Daniel!
EV1-DanielC
Meep. :-)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.