LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2008, 11:13 AM   #1
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
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
 
Old 05-15-2008, 11:21 AM   #2
polymath69
LQ Newbie
 
Registered: Oct 2004
Distribution: Debian, Ubuntu, DSL, TRK, etc.
Posts: 18
Blog Entries: 3

Rep: Reputation: 3
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

Last edited by polymath69; 05-15-2008 at 11:24 AM.
 
Old 05-15-2008, 11:27 AM   #3
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
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.
 
Old 05-15-2008, 11:29 AM   #4
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
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

Last edited by beadyallen; 05-15-2008 at 11:33 AM.
 
Old 05-16-2008, 03:02 AM   #5
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Original Poster
Rep: Reputation: 30
This was what i was looking for cheers
Quote:
Originally Posted by rayfordj View Post
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
 
Old 05-16-2008, 04:10 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Why not simply...?
Code:
gzip Apr-[0-3][0-9]-2008-*.log
 
Old 05-16-2008, 06:53 AM   #7
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
Quote:
Originally Posted by colucix View Post
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.
 
Old 05-16-2008, 07:53 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by rayfordj View Post
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)!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[gzip] appears in process table after gzip command completes redmanDBA Linux - General 0 02-26-2008 06:12 AM
apt-get update error: "gzip: stdin: not in gzip format" haertig Debian 0 08-02-2006 05:21 PM
Solaris 8 gzip issues- cannot gzip -d lynx sixosix Solaris / OpenSolaris 4 03-13-2005 03:17 PM
gzip Robin01 Linux - Newbie 4 09-13-2003 04:57 AM
Gzip futurist General 7 03-29-2002 03:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration