How to add files folders to an existing TAR archive

It is possible to append on existing TAR archive.

We can add additional files/folders to an already existing TAR archive.

For example:

Create 3 files named as file1 file2 file3

[root@linux midnight]# touch file1 file2 file3

List file created.

[root@linux midnight]# ls -l
total 0
-rw-r--r-- 1 root root 0 Oct 29 10:26 file1
-rw-r--r-- 1 root root 0 Oct 29 10:26 file2
-rw-r--r-- 1 root root 0 Oct 29 10:26 file3

Create tar archive named as file.tar using following command

[root@linux midnight]# tar -cvf file.tar file1 file2 file3
file1
file2
file3

List contains of tar file file.tar

[root@linux midnight]# tar -tf file.tar
file1
file2
file3

Create additional file

[root@linux midnight]# touch file4

Add file4 to existing file.tar

[root@linux midnight]# tar -rf file.tar file4

List files of file.tar and see 4th file is added.

[root@linux midnight]# tar -tf file.tar
file1
file2
file3
file4

 

2 thoughts on “How to add files folders to an existing TAR archive

  1. Hi there, I enjoy reading all of your post. I wanted to write a
    little comment to support you.

Leave a Reply

Your email address will not be published. Required fields are marked *