Tar multiple files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Tar multiple files
# 1  
Old 10-02-2006
Tar multiple files

Hi All,

There 2 files in the folder /temp/tst/
1.txt
2.txt

When I run the command

find /temp/tst \( -name "*.txt" \) -exec tar cf /temp/123.tar {} \;

it creates the tar file 123.tar with only one file in it and that is 2.txt.But if I use the command

find /temp/tst \( -name "*.txt" \) -exec tar cf /temp/123.tar {} + 1>/dev/null

it creates both the files in the 123.tar file which is what I want.

But I don't understand why is this happening.

Any comments experts?

Last edited by rony_daniel; 10-02-2006 at 09:31 PM..
# 2  
Old 10-03-2006
The + tells find to only run it once. It runs it like "tar -cf file.tar file1 file2", which includes both files in one archive, file.tar.

The version without the + runs tar twice, once for each file. tar does not automatically append, it replaces, so it replaces the first archive.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tar extract a multiple directories

i extract it through script, is there any way to script or automate to tar extract a tarfiles in multiple directories at once? Cannot open: No such file or directory tar: Error is not recoverable: exiting now for dir in `ls -d /tarfiles/*/ | sed 's/.$//'` do rm -f $dir/*.tar mv -f... (1 Reply)
Discussion started by: kenshinhimura
1 Replies

2. Shell Programming and Scripting

Extract a tar ball into multiple directories

#cat a BAC064DAL BAC063DAL BAC056PHX BAC066DAL BAC062PHX BAC062DAL BAC060DAL BAC058PHX BAC054PHX BAC051PHX # for i in `cat a` > do > tar xvf $a/$a*.tar* > done tar: /*.tar*: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: /*.tar*: Cannot... (3 Replies)
Discussion started by: kenshinhimura
3 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

5. 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

6. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

7. BSD

tape drives vs. tar with multiple directories

Hello, I have a little problem with backup & restoring files from tape drive. I am adding 3 directories to my tape, and it is OK: hades# tar -cvf /dev/nsa0 test test1 restore a test a test/level1 a test/myharddisk.img a test1 a test1/level1 a test1/myharddisk.img a test1/test.img a... (1 Reply)
Discussion started by: d3m00n
1 Replies

8. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies

9. UNIX for Advanced & Expert Users

Untaring *.tar.tar files

Hi all, How to untar a file with .tar.tar extension. A utility that i downloaded from net had this extension. Thanks in advance, bubeshj. (6 Replies)
Discussion started by: bubeshj
6 Replies

10. UNIX for Dummies Questions & Answers

how to tar to multiple tapes

how to tar to multiple tapes (1 Reply)
Discussion started by: sean dixon
1 Replies
Login or Register to Ask a Question