Unix/Linux Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Hpux find tar gzip

HP-UX


Tags
find tar gzip

Closed    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 08-05-2016
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 April 2017, 4:04 PM EDT
Location: Aachen, Germany
Posts: 10,671
Thanks: 262
Thanked 3,280 Times in 3,022 Posts
Does the tar without gzip contain anything?
The Following User Says Thank You to RudiC For This Useful Post:
royinfo.alain (08-08-2016)
Sponsored Links
    #9  
Old Unix and Linux 08-05-2016
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 23 April 2017, 2:13 PM EDT
Location: Simplicity
Posts: 3,498
Thanks: 273
Thanked 1,160 Times in 1,053 Posts

Code:
find * -type f -mtime -$nb_days -print | xargs tar cf - | gzip > $MAITUT/BCK_DATA.tar.gz

Maybe the following works as well (and handles special characters in filenames better)

Code:
find * -type f -mtime -$nb_days -exec tar cf - {} + | gzip > $MAITUT/BCK_DATA.tar.gz

Both methods will fail if there are too many files: a second tar is invoked that certainly obscures the tar file.
The Following User Says Thank You to MadeInGermany For This Useful Post:
royinfo.alain (08-08-2016)
Sponsored Links
    #10  
Old Unix and Linux 08-08-2016
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 21 April 2017, 10:12 AM EDT
Location: Lancashire, UK
Posts: 3,074
Thanks: 1,284
Thanked 590 Times in 534 Posts
These options will struggle with too many filenames because xargs will produce multiple commands from the list. The command xargs (as I understand it) will take the input list and try to make a single command line from the options given using the input as described or as the final part of the line by default. If the line is going to exceed the maximum command length, then xargs will loop on the command with the remaining input.

With a tar this could be disastrous because the potential multiple tar commands would not be able to be disentangled if you needed to read it back.

If this was AIX, I would recommend writing the names of the required items into a temporary file and passing that with the -L flag, but I'm not sure that HP-UX or anything else supports that. Solaris might use -I (capital i) instead. You would have to read the manual page and look for a flag to accept a list or input file.


Could you consider cpio or other tools instead?


Robin
The Following User Says Thank You to rbatte1 For This Useful Post:
royinfo.alain (08-08-2016)
    #11  
Old Unix and Linux 08-08-2016
rezasadeghi rezasadeghi is offline
Registered User
 
Join Date: Dec 2015
Last Activity: 18 March 2017, 7:43 AM EDT
Posts: 12
Thanks: 1
Thanked 2 Times in 2 Posts
hello
you can use this code:


Code:
find * -type f -mtime -$nb_days -print -exec tar cvf {} \; && bzip2 *.tar




Moderator's Comments:
Hpux  find tar gzip Please use CODE tags as required by forum rules!

Last edited by RudiC; 08-08-2016 at 06:41 AM.. Reason: Added CODE tags.
The Following User Says Thank You to rezasadeghi For This Useful Post:
royinfo.alain (08-08-2016)
Sponsored Links
    #12  
Old Unix and Linux 08-08-2016
vbe's Unix or Linux Image
vbe vbe is online now Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 23 April 2017, 5:35 PM EDT
Location: Switzerland - GE
Posts: 6,406
Thanks: 269
Thanked 537 Times in 499 Posts
Looking at Rudi's

Code:
find * -type f -mtime -$nb_days -print | xargs tar cf - | gzip > $MAITUT/BCK_DATA.tar.gz

I would say xarg is useless and will give you trouble and is maybe what is upsetinf you from the beginning
Im quite sure

Code:
find * -type f -mtime -$nb_days -print |  tar -cvf - | gzip > $MAITUT/BCK_DATA.tar.gz

should work but I have no HP-UX or any unix to give try at the moment...
The Following User Says Thank You to vbe For This Useful Post:
royinfo.alain (08-08-2016)
Sponsored Links
    #13  
Old Unix and Linux 08-08-2016
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 April 2017, 4:04 PM EDT
Location: Aachen, Germany
Posts: 10,671
Thanks: 262
Thanked 3,280 Times in 3,022 Posts
Hmmm - isn't it that tar expects the files to create an archive from on the command line? Doesn't it use stdin only when extracting from a data stream?

So xargs WOULD be needed to supply the file names coming from find on stdin as parameters on the command line to tar.

Above proposal yields

Code:
tar: no files or directories specified

on FreeBSD, and

Code:
tar: Cowardly refusing to create an empty archive

on my linux machine.
The Following User Says Thank You to RudiC For This Useful Post:
royinfo.alain (08-08-2016)
Sponsored Links
    #14  
Old Unix and Linux 08-08-2016
stomp stomp is offline
Registered User
 
Join Date: May 2016
Last Activity: 23 April 2017, 4:35 PM EDT
Posts: 186
Thanks: 10
Thanked 66 Times in 61 Posts
tar: Under linux you can use -T - to read filenames from stdin.

Pack:

Code:
find /path -type f | tar -T - -cf - | gzip >file.tar.gz

Unpack:

Code:
gzip -dc file.tar.gz | tar -xf -

I doubt that HP-UX tar already has this option. But maybe. I recommend cpio as the better option here too, because it's designed right from start to work with files from stdin.

Quote:
Originally Posted by royinfo.alain
I tried with the f and have no errors..

the command that I used :
Code:

find * -type f -mtime -365 -print | xargs tar -cvf | gzip > $MAITUT/BCK_DATA.tar.gz
tar -cvf has not argument for -f. What was recommended to you is this command(dash at the end): tar -cvf -

Last edited by stomp; 08-08-2016 at 09:00 AM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help ASAP - FIND - TAR - GZIP royinfo.alain UNIX for Beginners Questions & Answers 2 08-04-2016 04:46 PM
Failed to use find-tar-gzip together Chetanz UNIX for Dummies Questions & Answers 7 02-01-2013 04:23 PM
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
From HPUX tar to Linux tar iarot Filesystems, Disks and Memory 4 02-14-2002 03:10 AM



All times are GMT -4. The time now is 05:43 PM.