[LUGSB] grep, maybe

Chris Wright dhasenan at gmail.com
Thu Oct 29 11:49:14 EDT 2009


something like:
grep -r --files-with-match $PATTERN . | sed 's/\/[^\/]*$//' | xargs mv $DEST

1. find the files
2. get the folders for each file, by stripping off everything after the last '/'
3. move the results to the destination folder

2009/10/29 Maurice <mauricep at cds-cumberland.org>:
> Looking for some guidance;
>
> 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...
>
> I'm thinking grep, but don't know the correct syntax to make all this
> happen.
> I can easily find all the folders (1949 of them) and the word match 3923
> times within the text file(s)...
>
>
> Any ideas???
>
>
>
>
> --
> -Maurice Pelletier
> Child Development Services - Cumberland County
> 50 Depot Road
> Falmouth, ME 04105
> 207-781-8881 (voice)
> 207-781-8855 (fax)
>
> www.cds-cumberland.org
>
>
> "Linux -- it's not just for breakfast anymore..."
> -Moe
>
>
>
> _______________________________________________
> lugsb mailing list
> lugsb at mail.fsl.cs.sunysb.edu
> To unsubscribe from this list, go to:
> http://www.fsl.cs.sunysb.edu/mailman/listinfo/lugsb
>


More information about the lugsb mailing list