Is there any way to add to a tarball made in this fashion


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is there any way to add to a tarball made in this fashion
# 1  
Old 01-28-2010
Is there any way to add to a tarball made in this fashion

Hello,

I am wondering if there is an easy way to add a file to a tarball rather than extracting, adding, then remaking the tarball.

The tarball was made in this way:

Code:
tar -cpvzf .wine.tar.gz .wine/

If I had a file to the .wine/ dir (or if I just wanted to add a file to the tarball), I would like to add it to .wine.tar.gz rather than having to un(tar/gzip) it, add it to the dir, and then re-tarball it (yes I know I could just add it to .wine/ then redo the above command; I'm just looking to understand principles, here, as if I deleted the dir after I tarballed it).

With thanks,
Narnie
# 2  
Old 01-29-2010
Code:
gunzip .wine.tar.gz
tar -Avf .wine.tar [more files - directories]
gzip wine.tar

# 3  
Old 01-29-2010
Quote:
Originally Posted by jim mcnamara
Code:
gunzip .wine.tar.gz
tar -Avf .wine.tar [more files - directories]
gzip wine.tar

So I take it there is no way to do what I was asking? It must be decompressed with gunzip, appended, the re-gzipped? Too bad it can't work more like zip files, of course in other ways, tar is much more powerful.

I'm curious tho, in what I've read in the past about tarballing, if it is tarballed using the -z argument, each file is individually gzipped then added to the tar. I was reading a text written in 1999, tho (SAM'S teach yourself shell programming in 24 hours, which was an excellent starting point).

I just tried the above and, of course, it worked. So has the behaviour of the -z arg changed to adding all the files to the tar then gzipping it? I'm curious because this has implications in creating a large tar file that if it were done along the way would be smaller vs creating a tar, then gzipping, which might create storage problems.

Thanks for you patience,
Narnie
# 4  
Old 01-29-2010
if you have access to GNU tar, you can use --append (-r)

---------- Post updated at 04:02 PM ---------- Previous update was at 03:59 PM ----------

sorry, scratch that - you can do it w/ tar or gtar (instead of tar cf tarfile file1 file2 etc. do tar rf tarfile newfiletoadd)
# 5  
Old 01-30-2010
Quote:
Originally Posted by droog72
if you have access to GNU tar, you can use --append (-r)

---------- Post updated at 04:02 PM ---------- Previous update was at 03:59 PM ----------

sorry, scratch that - you can do it w/ tar or gtar (instead of tar cf tarfile file1 file2 etc. do tar rf tarfile newfiletoadd)
Doesn't work on compressed files as above. The output for viewing pleasure

Code:
$ tar rf test.tar.gz test2
tar: Cannot update compressed archives
tar: Error is not recoverable: exiting now

I'll just write a script and gunzip it and gzip it back. Thanks all. Was hoping for a more elegant soln. Perhaps this is what zip programs do in the background anyway.

Yours,
Narnie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I add a log file path to a vi file to monitor all the changes made to the file?

I'm curious to know how do I add an empty log file (test1.log) to an existing text file to monitor all the changes made to a.txt. Is this expression export PATH=$PATH:/home/test1.log right to be added to the text file a.txt? (5 Replies)
Discussion started by: TestKing
5 Replies

2. UNIX for Beginners Questions & Answers

Creating a tarball on Solaris issue with errors

Hi All, We are planning to migrate from Solaris to AIX, and we have a requirement to move all files modified in last 7 days to AIX. i found many helpful forums on this site but somehow the issue was still not solved: Used the following command from the directory which we want to scan ... (6 Replies)
Discussion started by: nikhil8
6 Replies

3. Shell Programming and Scripting

Self extracting tarball

I was wondering if anyone can point me to some topics, material, or tutorials that can help me write a shell script that creates a second script that is a Self-extracting tarball. Don't want any actual code obviously because this is a school project, but I feel my teacher didn't well cover the... (3 Replies)
Discussion started by: canes27
3 Replies

4. Shell Programming and Scripting

Extract compressed tarball to folder?

This is for Red Hat Enterprise Linux Client release 5.7 (Tikanga). Wanna extract entire contents of a tar.gz to a folder of my choosing. Thanks (2 Replies)
Discussion started by: stevensw
2 Replies

5. Shell Programming and Scripting

tarball of current directory

I wanna make a backup tarball. I wanna write a script that makes tarball of the current directory. There are lots of files so I cant type all files, I wanna make the tarball by excluding few files. Like there 1000 files in a directory I wanna create a tarball containing 98 files of that... (1 Reply)
Discussion started by: nishrestha
1 Replies

6. Shell Programming and Scripting

Unpack individual files from tarball

Say you don't want to unpack the whole thing, just individual files or directories within a .tgz. How to do this? (1 Reply)
Discussion started by: stevensw
1 Replies

7. UNIX for Advanced & Expert Users

Size of a tarball without untarring - Catch parent tar ball has sub tars

hi, I am in a weird situation. I have a parent tarball which contains 2 sub tarballs. The structure is such : Parent.tar.gz ---- > child1.tar.gz and child2.tar.gz I need to get the size of the parent tarball without untaring it I know that the command is gunzip -c parent.tar.gz | wc -c ... (1 Reply)
Discussion started by: mnanavati
1 Replies

8. Shell Programming and Scripting

formatting lines in a particular fashion

i have some 100 of lines from a script o/p into a file called naveed.txt below some of the lines: 1-GH32X, CC, AMR, Number of Intervals Not Inserted: 1 / 95 1-150KP1, CC, AMR, Number of Intervals Not Inserted: 1 / 96 1-VWEMR, CC, AMR, Number of Intervals Not Inserted: 1 / 98 1-15HM1A, CC,... (5 Replies)
Discussion started by: ali560045
5 Replies
Login or Register to Ask a Question