I have a tar compressed archive tar.bzip2 (created using
tar jcf), which contains a file named data.txt (1).
On the other side, I have another file also named data.txt (2).
Is there a way to append file (2) to the end of file (1) without untar bz2 archive, append file and then tar it back again?
By the way, I already did the three steps, I'm asking just for curiosity (or 'out of curiosity'... not sure about this expression in English).
I've been looking for the right option, but I cannot find it out:
-roption tells me 'abort', I guess because I tried to append a file which already exists in archive.
-ucannot update compressed archives, although I think it will only replace (1) by (2).
-Aalso tells me 'abort'. I'm not really sure what this option does. It seems to add the files in one archive to another existing archive. So it's not what I want.
I'm using GNU tar 1.15.1 over Linux.
I think I didn't explain it well enough, so I better use an example:
I have a file named data.tar.bz2 which contains a file named data.txt (1). Its contents could be
I have another file also named data.txt (2). Its contents could be
My purpose is that the file contained in data.tar.bz2 has both (1) and (2) file contents in one file named, of course, data.txt:
In other words do this using one command, without decompressing, untar, create temporal directories, etc...:
mkdir $tempDir tar jxf data.tar.bz2 -C $tempDir cat data.txt >> $tempDir/data.txt tar jcf data.tar.bz2 -C $tempDir data.txt rm -r $tempDir
Yes, I want to append, but
-r option won't work because, if I'm not wrong, it appends files to archive, but it does not append the contents of an existing file in the archive. Hope this clarifies... not sure at all xD