On Thu, Oct 29, 2009 at 11:38 AM, Maurice <mauri...@cds-cumberland.org> wrote:
> 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...

  Well, the following will search for any file containing "moe"
(exactly), and list matching files:

        grep -l -r moe /path/to/top/level/directory

  If you want a case-insensitive search (match "moe", "Moe", "MoE", etc.):

        grep -i -l -r moe /path/to/top/level/directory

  If you want to search for multiple names, separate them by vertical
bars (|).  You will have to quote the search string to keep the bars
from being interpreted by the shell:

        grep -i -l -r 'moe|larry|curly' /path/to/top/level/directory

  Moving just the files would be pretty easy.  Moving the
*directories* would be trickier.  We can't move it when grep is still
in the directory, so we'll have to save a list somewhere, then parse
the list to find the directory names, then eliminate the duplicates,
then move the directories.

-- Ben
_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

Reply via email to