The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 3 Weeks Ago 09:37 AM
How to find whenther given value is in betwwen min and Max in unix shell scripting pinky UNIX for Dummies Questions & Answers 5 07-27-2007 07:52 AM
Scripting to find the size of the folder victorvvk Shell Programming and Scripting 2 03-17-2005 03:14 AM
UNIX find by time scripting budrito UNIX for Advanced & Expert Users 1 10-08-2004 02:19 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 03:38 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-12-2008
Registered User
 

Join Date: Nov 2006
Posts: 14
Scripting using the FIND command

I'm working on a 'find' command which uses the -exec option to tar a listing of files that it finds. Is there a single option available that would both 1) create the TAR file if it doesn't exist and/or 2) update the TAR file if it already exists?

Currently when I want manually create a TAR file and then add files to it I need to issue two different options to the TAR command. In other words, my command sequence needs to look like:

tar -cvf myTarFile.txt fileA.txt
tar -uvf myTarFile.txt fileB.txt
tar -uvf myTarFile.txt fileC.txt

So in the first iteration I have to include the -c (e.g. create TAR file) option. And in subsequent iterations I have to include the -u (e.g. update TAR file) option.

I want to avoid programatically having to issue a different command for the first iteration. Is this possible?

Any help would be greatly appreciated!!!
Reply With Quote
Forum Sponsor
  #2  
Old 08-12-2008
Registered User
 

Join Date: Jun 2008
Posts: 95
You can issue tar -uvf myTarFile.txt as the first command.(before iteration)
Then in the iteration use tar -uvf myTarFile.txt filei.
Reply With Quote
  #3  
Old 08-12-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 567
Use pax instead of tar and you won't need to issue two commands. After creating the archive you can use tar on it.

Code:
pax -w -f myTarFile.txt fileA.txt fileB.txt fileC.txt
tar tvf myTarFile.txt
Reply With Quote
  #4  
Old 08-12-2008
Registered User
 

Join Date: Nov 2006
Posts: 14
Thank you both for the solutions. Great help...I appreciate it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0