1

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
user25
  • 41

2 Answers2

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 
xenoid
  • 10,597
-1

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)

xenoid
  • 10,597