Failed to use find-tar-gzip together | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Failed to use find-tar-gzip together

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-31-2013
Chetanz Chetanz is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 3 July 2013, 11:09 AM EDT
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Failed to use find-tar-gzip together

Hello

I am trying to select multiple files older than 14 days and create a single compressed file out of it. (AIX Release 3 Version 5)

I am trying to achieve it by following


Code:
tar -cvf db01_log.tar `find . -name "db01*.log" -mtime +14" -print`| gzip > db01_log.tar

however it just created a tar file and not tar.gz file

could you please suggest on this?

Thanks and Regards
Chetanz

Last edited by Scott; 02-01-2013 at 11:29 AM.. Reason: Not an AIX problem. Thread moved.
Sponsored Links
    #2  
Old 01-31-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 15 October 2014, 5:08 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,455
Thanks: 8
Thanked 546 Times in 524 Posts
Write tar to stdout = -
Code:
tar -cvf - `find . -name "db01*.log" -mtime +14" -print`| gzip > db01_log.tar

Sponsored Links
    #3  
Old 02-01-2013
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 21 October 2014, 5:38 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,285
Thanks: 45
Thanked 824 Times in 651 Posts
DGPickett is correct: either "tar" writes to a file (then the pipe is empty) or to <stdout>, but not both. There are some other things with your code you might want to change:

First, obviously, you shouldn't use backticks any more. Use "$(...)" instead.

Second: "gzip" is - because of the way it works - a single-threaded program. If the amount of data you compress is huge it might take a very long time. Even if your system has several processors you will always use only one. If you want to overcome this you will have to distribute the files to back up over as many "tar"s as there are processors (sort them by size and use a round-robin scheme to balance the sizes) and then gzip each tar. This way you put all system processors to use.

I hope this helps.

bakunin
    #4  
Old 02-01-2013
Chetanz Chetanz is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 3 July 2013, 11:09 AM EDT
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Hello DGPickett and Bakunin

Thanks for your quick response

I used the following, word to word and space to space

But it created only the tar file and no gz file at all


Code:
tar -cvf - `find . -name "db01_rman*04*Jan*.log" -mtime +14 -print`| gzip > db01_rman04Jan.log.tar

Please suggest

Thanks and Regards
Chetanz
Sponsored Links
    #5  
Old 02-01-2013
MichaelFelt MichaelFelt is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 December 2013, 7:33 AM EST
Location: on the road for work; home is private time
Posts: 311
Thanks: 6
Thanked 76 Times in 71 Posts
if you can live without tar use:


Code:
find ... criteria ... | backup -if - | bzip2 >myfile.bff.bz2

or gzip if you prefer that. bzip2 was my habit speaking.
Sponsored Links
    #6  
Old 02-01-2013
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 21 October 2014, 5:38 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,285
Thanks: 45
Thanked 824 Times in 651 Posts
Actually this should have done what you (and we) expected it to do, but when you insist in naming a gzipped tar-file "*.tar" the OS will not put any obstacles before you.

This means: replace "> something.tar" with "something.tar.gz" and - voilá!

You will find out that the output you named ".tar" is no tar file at all when you try to untar it. It probably will complain about some "checksum error", which is, because it simply is no tar-file. But if you try to unpack it by:


Code:
mv your.tar your.tar.gz
gzip -cd your.tar.gz | tar -xf -

You will notice that this works. (gzip is just a bit picky about file extensions)

I hope this helps.

bakunin
Sponsored Links
    #7  
Old 02-01-2013
MichaelFelt MichaelFelt is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 December 2013, 7:33 AM EST
Location: on the road for work; home is private time
Posts: 311
Thanks: 6
Thanked 76 Times in 71 Posts
i read over that. the eye sees what it wants to see!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find + tar + gzip + uunecode/email --> in one command? kchinnam Shell Programming and Scripting 3 03-02-2012 02:25 PM
tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file ahSher UNIX for Dummies Questions & Answers 2 04-02-2009 04:43 AM
tar and gzip tungaw2004 UNIX for Dummies Questions & Answers 3 06-22-2007 03:21 AM
tar/gzip/gz...which one to use? abhijeetkul UNIX for Advanced & Expert Users 5 03-24-2006 02:00 AM
TAR and GZIP help VandeMatram UNIX for Dummies Questions & Answers 3 03-17-2006 06:35 AM



All times are GMT -4. The time now is 05:36 AM.