Search code examples
bashunixgzipglob

How to Glob all files in a directory match


I have a uniform directory structure several layers deep. Lets say CLIENT/USER/YEAR/TYPE/files

ex: client1/user1/2012/personal_files/file1.txt

what I want to do is compress all files from 2011.

essentially gzip */*/2011/*/*

This seems like it should be easy to do, but I can't seem to figure out how. I could always write nested for loops, but isn't there a better way?

Thanks


Solution

  • Try: for F in */*/2011/*/* ; do gzip "$F" ; done