0
I have a file named archive.tar and I want to append its contents (archive.tar is a backup file coming from a text file) to another file. I use the following command that doesn't seem to work:
tar -tvf archive.tar | cat archive.tar >> file
0
I have a file named archive.tar and I want to append its contents (archive.tar is a backup file coming from a text file) to another file. I use the following command that doesn't seem to work:
tar -tvf archive.tar | cat archive.tar >> file
0
From the tar
man page:
-A, --catenate, --concatenate append tar files to an archive
So, assuming that your have a big.tar
that you want to expand with the contents of more.tar
, just use:
tar -A -f big.tar more.tar
0
From the tar
man page:
-O, --to-stdout extract files to standard output
So if you want to append the uncompressed text contents of the files in the tar to an existing text file, use:
tar -Oxf more.tar >> appendedfile.txt
tar -tvf
only lists the contents of the tar, you have to extract the data somehow. If you want to append the list of files in the tar to an existing file, use
tar -tf more.tar >>tarfiles.txt
tar -tvf more.tar >>tarfiles.txt
(with -v
you also get the file sizes/flags)
Thank you so much!! – user25 – 2019-12-27T11:52:20.270
may I ask why is it necessary to add the x to the tar -Oxf command? – user25 – 2019-12-27T11:58:21.713
Because -x
is what make tar
extract the data. -t
only lists the contents. – xenoid – 2019-12-27T16:46:36.157
@user25 If thie answer solves your problem, please consider accepting the answer to help others. – xenoid – 2019-12-27T16:47:04.477
I edited it, I hope it's more comprehensible now – user25 – 2019-12-27T00:00:49.457