LinuxQuestions.org
Register a domain and help support LQ
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 09-22-2008, 03:09 PM   #1
rev1976
LQ Newbie
 
Registered: Nov 2007
Posts: 3

Rep: Reputation: 0
Find file and gzip it


Hi all,

I would like to create a script that will find all files and gzip them. So far this is what i have but it's not working. Not sure if i have the syntax correct:

find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*.001" -mtime 0 -type f | xargs gzip

I also tried this:

gzip 'find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*.001" -print'

Any help would be greatly appreciated. Thanks.
 
Old 09-22-2008, 05:16 PM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by rev1976 View Post
Hi all,

I would like to create a script that will find all files and gzip them. So far this is what i have but it's not working. Not sure if i have the syntax correct:

find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*.001" -mtime 0 -type f | xargs gzip

I also tried this:

gzip 'find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*.001" -print'

Any help would be greatly appreciated. Thanks.
I'd do this

Code:
find /data/db2inst1/backup -name '*.0.db2inst1.NODE0000.CATN0000.*.001' -mtime 0 -type f -exec gzip '{}' \;
Just make sure that the -name mask is good. If it's not working, let us know what error do you get. On a first sight all seems correct.
 
Old 09-22-2008, 06:20 PM   #3
rednuht
Member
 
Registered: Aug 2005
Posts: 239
Blog Entries: 1

Rep: Reputation: 31
Code:
find /etc -type f -mtime -7  -print0 | xargs -0 tar cvzf /tmp/etc.tar.gz
is how I backup /etc/ for the last weeks worth of changes.
note the find -print0 and xargs -0 to avoid files with spaces etc.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Split a gzip file ZAMO Linux - Server 6 08-21-2012 11:30 AM
[gzip] appears in process table after gzip command completes redmanDBA Linux - General 0 02-26-2008 07:12 AM
gzip in new file salmanucit Linux - Software 6 06-30-2007 09:32 AM
gzip a directory into a file tcma Linux - Software 4 10-07-2004 03:51 AM
How to gzip a file SnowSurfAir Linux - Software 5 07-31-2003 02:09 PM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration