Is it possible to append on existing TAR archive?
Yes we can add additional files/folders to an already existing TAR archive. The โTARโ saves many files together into a single tape or disk archive, and can restore individual files from the archive.
It is very useful in such conditions like when we want to send a lot of files via email, transfer files from one machine to another etc.
We already discussed the the basic switches of TAR command in one previous session. Click here for more details TAR command usages. Here I’m explaining one of the useful TAR switch.
It will help you to add more files/folders into an existing TAR archive. The “-r or –append” option with TAR command will do this.
Syntax
tar -rf archive.tar file3.txt
This TAR archive contains two files file1.txt and file2.txt
Example
Test files & creating tarball
[root@vps ~]# touch file1.txt [root@vps ~]# touch file2.txt [root@vps ~]# touch file3.txt [root@vps ~]# tar -cvf archive.tar file1.txt file2.txt
Listing files in archive using -t
[root@vps ~]# tar -tf archive.tar
file1.txt
file2.txt
Adding a file to TAR archive
[root@vps ~]# tar -rf archive.tar file3.txt
Check now!
[root@vps ~]# tar -tf archive.tar
file1.txt
file2.txt
file3.txt
That’s it dude!! Sometimes, this will be very useful, if you created a TAR for a big directory and need to add few newly created files into your already created tarball. Just append those files by using these switches ๐
Read also
1, 20+ Rsync command switches
2, Tar command with example
3, LSOF command details
15+ tar command usages with examples โ Unix/Linux
This is one of the most commonly using Linux command. This is very similar to the ZIP concept in Windows platform, what we are using commonly to save multiple file together.
The โtarโ saves many files together into a single tape or disk archive, and can restore individual files from the archive. It is very useful in such conditions like when we want to send a lot of files via email, transfer files from one machine to another etc.
Here I am explaining some common and useful switches and it usages with examples. Also, by using TAR we can compress and decompress files and make a single file archive to transfer file. In Linux almost all packages are available in internet in TAR file format. READ MORE..
If you’re interested to learn about Docker please check this category – Docker
It doesn’t work to append a folder
You should have specified that this does not work on compressed archive, which is what 99% of tar calls use, so it’s virtually useless.
Create RAR online for free freetools.site/file-compressor/rar