Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep, maybe



On Thu, Oct 29, 2009 at 11:38 AM, Maurice <mauricep-dJH4IiyFVKEZfdn3qmwGpR2eb7JE58TQ at public.gmane.org> wrote:
>
> I have several files within several folders (5 files per folder, and
> thousands of folders) that I need to search a text file within each
> folder for a word match (like three_little_pigs.txt, and I need to find
> "moe", if he's listed) and then when a match is found I need to move
> (not copy) that entire folder (and it's 3~5 files contained within) to
> another location...

You'll want to script this with something like:

pig=moe
dest=/some/dir
for d in $*; do
  grep -q $pig $d/*.txt && mv $d $dest
done






BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org