![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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!!! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You can issue tar -uvf myTarFile.txt as the first command.(before iteration)
Then in the iteration use tar -uvf myTarFile.txt filei. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Thank you both for the solutions. Great help...I appreciate it.
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|