3

I have a bunch of tar files such as a.tar b.tar. I use the following command to merge two tar files :

tar --concatenate --file=a.tar b.tar

However, --concatenate is not support on mac terminal 10.7.4 . What I need to do ?

3
  • try tar --file=Merged.tar --create file1.txt file2.txt and tell me if that is what you're looking for. If it is, post back and i will explain what i just showed you. This is basically how you make a "tar ball"
    – pneumatics
    Commented Nov 9, 2012 at 23:48
  • check my edit ? this was helpful @AlanTuring
    – cat916
    Commented Nov 9, 2012 at 23:51
  • it should still hold true for tar files, give it a swirl. Do you want me to post an answer?
    – pneumatics
    Commented Nov 9, 2012 at 23:53

1 Answer 1

3

There's a wonderful notion in the tar realm called a tar-ball. Basically it behaves very much the same way a real tarball would. It's sticky and you can throw stuff at it and it will stick!

So the basic Tar usage is:

tar --file=path_to_tarball --subcommand [--subcommand] \ [path_to_payload [path_to_payload]]

now let's see it in an example.

tar --file=Merged.tar --create file1.txt file2.txt

This creates a tarball of the 2 files file1 and file2. As i said earlier you can throw things at the tarball and it will still be fine!

tar --file=Merged.tar --append file3.txt

So as you can see the tarball just gets bigger and bigger!

Since you can imagine this to be a rather big ball lying around after some time, perhaps you want to retrieve something from it after a while? Or maybe even delete it?

To extract a file out of the tar ball we have

tar --file=Merge.tar --extract fileX.txt

and to delete it

tar --file=Megre.tar --delete fileX.txt

for a list of other awesome things you can do with the tar tool, head on over to MacTech

2
  • +1 thanks AlanTuring for the link and some helpful stuff
    – cat916
    Commented Nov 10, 2012 at 0:17
  • you aint going to accept it lol?
    – pneumatics
    Commented Nov 10, 2012 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .