Adding to that: for FILE in $( grep -lRF moe somedirectory/* ) ; \ do echo mv -v $(dirname "$FILE") destination_path ; done Remove the "echo" and repeat if it looks Ok. Uses dirname to move the containing directory. -Jamie On Thu, 29 Oct 2009, James Gray wrote:
On Thu, Oct 29, 2009 at 11:41 AM, Maurice <mauricep@cds-cumberland.org> wrote:
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)...
I think this should do the trick. I haven't tested it cause I don't want to have *my* files moved around.
for FILE in $( grep -lRF moe somedirectory/* ) ; do mv "$FILE" destination_path ; done
~James _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
participants (1)
-
Jamie Guinan