Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that gzip compress a file, but I would want to know. How to compress a list of files, each file in their own GZIP file ?

I need to use the list of a folder: ls log.2011 And for each file create a zipped file.

Any ideas ?

share|improve this question
So your file log.2011 lists compressed files? You want them all compressed as a single archive right? I'd look at using tar. – Doc Jul 11 '11 at 15:59
do you have a bunch of folders with x amount of files in and you want a zip for each folder? because multiple files requires tar aswell. – squarebear Jul 11 '11 at 16:13

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.

share|improve this answer

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .