LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gzip help (https://www.linuxquestions.org/questions/linux-newbie-8/gzip-help-642414/)

mahmoud 05-15-2008 11:13 AM

gzip help
 
Hi
i have used this command before but i cant remember the syntax quite well
its
ls -l Apr-[0-3][0-9]-2008-*.log | xargs -i@ gzip@
but it is not working
error : xargs: gzip@: No such file or directory

polymath69 05-15-2008 11:21 AM

Quite right you can't remember the syntax. What are you trying to do?

If you want to collect some log files into an archive, you don't want the -l on the ls command. You don't even want to be using the ls command. And you don't want gzip, you want tar.

tar cfz sometarfile.tgz Apr-[0-3][0-9]-2008-*.log

cfz: c = create, f = filename will be given, z = compressed

rayfordj 05-15-2008 11:27 AM

I can only guess that you may be after something like this:

Code:

ls -1 Apr-[0-3][0-9]-2008-*.log | xargs -i  gzip {}
the dash one to ls prints one filename per line and then xargs passes that to gzip so that each *.log is compressed to a file of the corresponding filename plus a .gz extension.

Hope this helps.

beadyallen 05-15-2008 11:29 AM

Or if you're trying to zip up everything separately, use something like:
Code:

find ./ -maxdepth 1 -iname 'Apr-[0-3][0-9]-2008-*.log' -exec gzip {} \;
edit: Beaten to it. lol

mahmoud 05-16-2008 03:02 AM

This was what i was looking for cheers
Quote:

Originally Posted by rayfordj (Post 3154245)
I can only guess that you may be after something like this:

Code:

ls -1 Apr-[0-3][0-9]-2008-*.log | xargs -i  gzip {}
the dash one to ls prints one filename per line and then xargs passes that to gzip so that each *.log is compressed to a file of the corresponding filename plus a .gz extension.

Hope this helps.

thanks alot that helped everyone

colucix 05-16-2008 04:10 AM

Why not simply...?
Code:

gzip Apr-[0-3][0-9]-2008-*.log

rayfordj 05-16-2008 06:53 AM

Quote:

Originally Posted by colucix (Post 3155002)
Why not simply...?
Code:

gzip Apr-[0-3][0-9]-2008-*.log

My guess is it is desired to have each log compressed individually for easy "lookup" to review a single instance (?day?) should it be needed. ;)

colucix 05-16-2008 07:53 AM

Quote:

Originally Posted by rayfordj (Post 3155126)
My guess is it is desired to have each log compressed individually for easy "lookup" to review a single instance (?day?) should it be needed. ;)

You are right. Indeed, the gzip command compresses files individually (unlike the zip command)! ;)


All times are GMT -5. The time now is 09:09 AM.