grep, maybe

David Hummel lemmuh-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Thu Oct 29 11:44:52 EDT 2009


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





More information about the Discuss mailing list