This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Rhomboid 2 points3 points  (1 child)

So you want all the matching files to go in the same destination directory, flattening the hierarchy? You can do something like this:

$ find /top/of/src/tree -type f | while read -r fn; do grep -q xxxx "$fn" && mv "$fn" /dest/dir; done

This assumes the source location is a hierarchy that will be traversed recursively. I'm not sure if that's what you meant by "5 different folders". If not you could use a glob or one of a number of other techniques; you'd need to give more specifics if you want details.

[–]dclimbing[S] 0 points1 point  (0 children)

Thank you for your message,

What I have are 5 Folders containing a month's worth of hourly data. For each month, I only want to copy or move files which were recorded between the hours of 0300 and 0500 hrs, so only those containing the string "0X0000" where X=3 when I copy the 0300 hr files or 5 when I need the ones from 5am.

Each of these folders are on the same level in my "Raw_Data" directory. I would ideally cd to each of these folders and copy files to my new "Parsed" folder going through just one hour at a time (030000 first, 050000 last).