How to GZIP all the files or a list of files from some path?

gzip will always compress each file into a single .gz file when given a list of files on its command line.

For example

$ gzip -r log.2011

to recursively walk the log.2011 directory and compress all files it finds, or

$ gzip log.2011/*

to compress only the files in the log.2011 directory without descending into subdirectories.


This will output a gz archive for each matching file, files are replaced by the archive:

gzip fileprefix*

Have a look to the '-r' flag too.