'find' and 'tar' combination


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting 'find' and 'tar' combination
# 1  
Old 02-06-2008
'find' and 'tar' combination

I'm trying to tar the files I get from the 'find' command result. However I can't make it run successfuly? This is for our archiving process.

Here is my script:
find /mnt/LOGS -mtime -10 -name "TUXLOG.*" -exec tar -cvf /mnt/LOGS/combine.tar {} \;

Im not sure why it is not working or it is even possible to use the 'tar' command with exec.

Appreciate your help.
# 2  
Old 02-06-2008
You command "find /mnt/LOGS -mtime -10 -name "TUXLOG.*" -exec tar -cvf /mnt/LOGS/combine.tar {} \;" with the "-c" recreate for each file founded par find another "combine.tar".

Better way to create a temporay file :
Code:
find /mnt/LOGS -mtime -10 -name "TUXLOG.*" > combine.lst
tar -cvf /mnt/LOGS/combine.tar -L combine.lst

WARNING: If /mnt/LOGS/combine.tar already exists, you must use "tar -uvf" ... Smilie
# 3  
Old 02-06-2008
The -uvf works!!

Thank you so much...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need help ASAP - FIND - TAR - GZIP

Hi, I need to combined in 1 line the execution below : find * -type f -mtime -$nb_days -print | xargs tar -cvf $MAITUT/BCK_DATA.tar gzip $MAITUT/BCK_DATA.tar.gz The fact that the TAR is very big, at the end I need to generate only the GZ file. The option z on the tar... (2 Replies)
Discussion started by: royinfo.alain
2 Replies

2. Shell Programming and Scripting

Using find for variable combination of perms

Hi, I'm trying to use find in kshell (AIX) to find all files with perms of write for other AND any execute bit set. e.g: r--r-x-w- would qualify and rw-rw--wx would qualify but ---rwxr-xr-x wouldn't qualify So far, I've been trying something like this: find . -type f -perm... (4 Replies)
Discussion started by: alanp36
4 Replies

3. Shell Programming and Scripting

Find and Tar a Folder

Hi all, I have created a function that looks for a folder in a particular directory, checks the date it was last modified and if its old then compress it. This works fine for files using gzip. However for folders I had to use tar. This is my function: compressOldFolder() { # $1 is... (10 Replies)
Discussion started by: TasosARISFC
10 Replies

4. Shell Programming and Scripting

Complex find and replace only 1st instance string with dynamic combination

test.txt is the dynamic file but some of combination are fix like below are the lines ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off = disabled the test.txt can content them in any order #cat test.xt ;wonder_off = ;wonder_off = disabled wonder_off = wonder_off =... (5 Replies)
Discussion started by: SilvesterJ
5 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. UNIX for Dummies Questions & Answers

Grep and find combination

Hello All, I'm trying the following:find . -name "*" -exec grep -ln "IsAlpha" {} \; It gives me file names only (having string "IsAlpha"), I want to get line numbers also, something like this: test 1: Line 52 test 1: Line 95 etc Is it possible to obtain using grep & find only. (5 Replies)
Discussion started by: nervous
5 Replies

8. UNIX for Dummies Questions & Answers

Combination of find -xargs & wc -l

Dear all, I have to calculate sum of record count of files of the specified directory. First I tried the following way which prints one or more outputs. How can I sum of this output? find /home/work/tmp/1/O/ -type f -print0 | xargs -0 wc -l | grep total 1666288 total 1073908 total ... (4 Replies)
Discussion started by: mr_bold
4 Replies

9. UNIX for Dummies Questions & Answers

Problem with find and tar

When I am doing the first command the result shows all the files, links, directories except the ones that contain the word logs find . -type f -o -type l -o -type d | grep -v logs But when I am trying to do this even the logs are getting tarred tar -cvf fdtvision.tar `find . -type f -o -type l... (2 Replies)
Discussion started by: venu_nbk
2 Replies

10. Solaris

Combination of gunzip and tar on Solaris

Hello I'm trying to use a combination of gunzip and tar to unpack and unzip a *.tar.gz file. I tried gunzip ~/myfile.tar.gz | gtar -x This will unzip the file, but it won't unpack. Any hints? thanks a lot Dan (5 Replies)
Discussion started by: dwidmer
5 Replies
Login or Register to Ask a Question