Results 1 to 10 of 13
hi there
i just wanted to ask is there a way to append files or folders into an already existing tar.bz2 archive?
i am writing a script that after its ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-28-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 35
tar.bz2 compression
hi there
i just wanted to ask is there a way to append files or folders into an already existing tar.bz2 archive?
i am writing a script that after its done doing it job, it compresses the acquired files into one tar.bz2 archive, i tired tar -jrf but for some reason i always end up getting this error
"tar: Cannot update compressed archives"
thanks
- 05-28-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,227
AFAIK, the answer to that is no. That said, there might be some special tools that would expand the archive in memory and allow you to add files which it could then re-tar and re-compress the archive. I just don't know what they might be, if they exist. For read-only operations, most Linux GUI file browsers such as Konqueror can expand and read bzip2 tar archives without problems, but they cannot add a file to them.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-28-2009 #3Linux Newbie
- Join Date
- Sep 2004
- Location
- UK
- Posts
- 161
Don't think you can do that. The compressed tar is a tar ball which is then compressed whereas a zip file is a collection of files that have been individually compressed. I think you will have to uncompress that tgz amd then append the files and then recompress it.
In a world without walls and fences, who needs Windows and Gates?
- 05-28-2009 #4Just Joined!
- Join Date
- May 2009
- Posts
- 35
k, fair enough
one last simple question, is there a way to redirect a file into a compressed one
for example instead of writing
vmstat 5 13 > stat
tar -rf archive.tar stat
is there a way to immediately redirect vmstat into and archive.tar with the name stat??
- 05-28-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,227
You could do something like this (maybe - I haven't tried it yet):
Alternatively, you could create a script to do it.Code:tar -rf archive.tar `vmstat 5 13 >stat ; echo stat`
---- A Little Later ----
Ok. I tried the technique shown above, and it works just fine on my CentOS 5.3 system.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-28-2009 #6Just Joined!
- Join Date
- May 2009
- Posts
- 35
this is not what i meant m8, i meant to ask if there is a way to archive smth from the get go without first saving it, your above script first saves stat into the current dictionary then compresses it, so that after its done we would have one stat file and one archived file.
is there a way to only have one archived file at the end of the process??
p.s: english is not the my first language, so if u didnt understand me i will repeat the question or smth
- 05-28-2009 #7Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
I am afraid that there's no straight way to do what you ask for. You could use a named pipe, which is nothing but a file that acts like a FIFO (check mkfifo), with that you can pass a data stream from one point to another. The problem is that tar can only store files with a name. You can't simply throw contents inside a tar file. It wouldn't be able to restore it to a file afterwards anyway.
You can create a temporal file in /dev/shm or /tmp though.
- 05-28-2009 #8Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,227
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-29-2009 #9Just Joined!
- Join Date
- May 2009
- Posts
- 35
- 05-29-2009 #10Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,227
Like I said, sometimes a script is the proper solution. One that takes a couple of arguments, such as the name of the archive.tar file and the number of iterations to vmstat so you can tailor it to your needs (the defaults can be the same values you use now) at runtime. That approach eliminates typos for the most part.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote

