TAR prob - Guru's please help


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users TAR prob - Guru's please help
# 1  
Old 01-20-2005
TAR prob - Guru's please help

I'm trying to tar 3000 files into a single tar file to be extracted on another server. Command I'm using:

find . -name '*cost*' -print| xargs tar -cvf mylist.tar (Note tar is contained on filesystem not tape drive which is what I want)

Above command works fine and displays all 3000+ file archived.

The problem is when i extract the file, it only extacts 34 of the files contained in the tar. Command used to extract:

tar -xvf mylist.tar

When I also query my tar file created (i.e. mylist.tar), it also display only 34files. Command used to display files:
tar -vtf mylist.tar

Any ideas whats I'm doing wrong please as any help would be appreciated to extract all files.

OS - TRU64 ver 4.0f

thanks
Bud.
# 2  
Old 01-20-2005
This is because xargs takes the files from the list output by find in the pipe a batch at a time, so your command is actually continually overwriting the tar file each time a new batch is taken - thus there are only 34 files in the argument list xargs gives to tar the last time xargs is invoked.

Do something like

Code:
find . -name '*cost*' -print | while read line; do
if [ ! -e mylist.tar ]; then
   tar cvf mylist.tar "$line"
else
   tar uvf mylist.tar "$line"
fi
done

It'll be slow but it'll work.

If that's not to your liking try using cpio or something else instead.

Cheers
ZB
# 3  
Old 01-20-2005
Most versions of tar allow you specify a file which contains filenames. Have a look in your manual pages.
# 4  
Old 01-21-2005
Thanks heaps guys, managed to solve the problem. The trip was to tar the file not from teh current directory (i.e where the files reside) but from the earlier directory. Zazzybob you were correct as well.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help from a C++ makefile guru

hello, i'm recompiling some c++ code for OSX and there are some bugs as the configure is not picking up some libs like atlas, pastix, etc, it should be finding either in standard path or with pkgconfig but it's not so i'm rewriting the Makefile. C++ territory is a bit of a stretch with all of... (0 Replies)
Discussion started by: f77hack
0 Replies

2. Shell Programming and Scripting

Shell script guru

Hey Gurus, Need help to modify the shell script. I am really new in the Linux/Unix world and dont familiar with shell scripting. SO bascially my script is running a ( curl ) with some endpoints and returning HTTP status code. Now i have a 50 different endpoints and cant make each and individual... (3 Replies)
Discussion started by: Zach Kadiwal
3 Replies

3. What is on Your Mind?

Noob and Guru

A long time ago, my computer crashed, at that time, I was using Windows98, but because I was a noob at computers, my friend recommended me apro to fix it for me.   He came, saw the computer, and asked if I had a backup/installation disk for Windows 98. I said no.   He thought about it for a... (1 Reply)
Discussion started by: vistastar
1 Replies

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

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

-- Need help from a AIX guru --

Hi alls I don't see any solution and I need to have feedback from other people... On a test machine (AIX 5.1) I've installed OpenSSH software on it (with openssl, prng, etc...) like is described on IBM AIX Docs. To control the installation I've rebooted the machine and all was ok (CDE was... (15 Replies)
Discussion started by: nymus7
15 Replies

7. UNIX for Dummies Questions & Answers

To all the Java guru...

Please forgive me if this is the wrong place for this post. I didn't see a good place to post this topic in. :D I would like to know what's the most popular and reliable Java IDE out there nowadays? A FREE one would be awesome! :D Thanks for your suggestion! Cheers! (10 Replies)
Discussion started by: laila63
10 Replies

8. UNIX for Advanced & Expert Users

what do most Unix guru's use ? :D

I wanted to know what email app most Sun solaris / unix gurus use ? I have become quite NON microsoft in the last few months in my studying solaris.. thanks simon2000 (6 Replies)
Discussion started by: simon2000
6 Replies

9. UNIX for Advanced & Expert Users

sun guru help!

I installed sun recommended cluster patches for solaris 2.5 on my solaris 2.5 server and then issued a shutdown -i6 -y -g0 to reboot the server but server failed to come back up. the server tries to boot up and goes through initialising memory then server freeze. I try to bring the server up... (7 Replies)
Discussion started by: hassan2
7 Replies

10. UNIX for Advanced & Expert Users

Perl Guru help

I am trying to install Perl 5.005 on solaris 2.5, following the perl installation guide in INSTALL file that comes with Perl software However, according to the installation procedure, it instruct me to to excute "make" command after running the Configure which I did but everytime I excute... (3 Replies)
Discussion started by: hassan2
3 Replies
Login or Register to Ask a Question