Scripting using the FIND command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting using the FIND command
# 1  
Old 08-12-2008
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!!!
# 2  
Old 08-12-2008
You can issue tar -uvf myTarFile.txt as the first command.(before iteration)
Then in the iteration use tar -uvf myTarFile.txt filei.
# 3  
Old 08-12-2008
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  
Old 08-12-2008
Thank you both for the solutions. Great help...I appreciate it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and Replace in UNIX Scripting

Hi, Need your advices, Input : select code,status,input from VIEW1.VIEWNAME where IDU_CD IN ('S','N') and status_col='derived')) union select code,status,input from VIEW1.VIEWNAME2 where date='#p1' Expected output : select code,status,input from VIEW1.VIEWNAME where... (2 Replies)
Discussion started by: Nandy
2 Replies

2. Shell Programming and Scripting

How to find a missing file sequence using shell scripting?

Hey guys, I want the below files to be processed with the help of BASH so that i will be able to find the missing file names : PP01674520141228X.gz PP01674620141228X.gz PP01674820141228X.gz PP01674920141228X.gz PP01675420141228X.gz PP01675520141228X.gz PP01676020141228X.gz . . . .... (4 Replies)
Discussion started by: TANUJ
4 Replies

3. Shell Programming and Scripting

how to find files and replace them in a directory in Shell scripting

I have a directory /java/unix/data In data directory i have so many files from which i want to find some files who look alike below.(there are number of such below such files as well different files too in the data directory) -68395#svg.xml -56789#ghi.xml -67894#gjk.org -56734#gil.txt I... (6 Replies)
Discussion started by: pratima.kumari
6 Replies

4. Shell Programming and Scripting

How to use grep & find command to find references to a particular file

Hi all , I'm new to unix I have a checked project , there exists a file called xxx.config . now my task is to find all the files in the checked out project which references to this xxx.config file. how do i use grep or find command . (2 Replies)
Discussion started by: Gangam
2 Replies

5. Shell Programming and Scripting

Need help with scripting (find and replace)

Hello. I've got to files (source and target). 1) target.txt: .... #: tracopt/mimeview/php.py:97 msgid "" ... (1 Reply)
Discussion started by: Naar
1 Replies

6. UNIX for Dummies Questions & Answers

Find and replace in all files using shell scripting

Hi all, I'm looking to find and replace a string in all HTML files within a certain directory, including subdirectories. Normally, I would play with this a little to get it to work, but I can't mess this up, so I'm going to ask here. Basically, I want to find "<title>" in all *.htm* files... (11 Replies)
Discussion started by: slothario
11 Replies

7. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

8. Shell Programming and Scripting

Scripting to find the size of the folder

Will any body help me by writing a script in unix to the find out the size of the Main folder which has some 5 to 6 subfolders which in turn has some file in each of these subfolders regards victorvvk (2 Replies)
Discussion started by: victorvvk
2 Replies

9. UNIX for Advanced & Expert Users

UNIX find by time scripting

Hi, I want to write a UNIX script that checks for any files older then 20mins in in a unix directory. If it does find a file then an email gets sent notifying the administrator. If no files are found then it doesn't do anything. Only thing I'm not so sure about writing is the finding of ... (1 Reply)
Discussion started by: budrito
1 Replies

10. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question