4. Tar commands:
Format for doing the tar from the files: tar -cvf .tar
—————————–OUTPUT——————————————————-
[root@kalwa2 zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Jun 14 09:02 test1.txt
-rw-r–r–. 1 root root 221 Jun 14 09:02 test2.txt
-rw-r–r–. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]# tar -cvf test.tar test1.txt test2.txt test3.txt
test1.txt
test2.txt
test3.txt
[root@kalwa2 zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Jun 14 09:02 test1.txt
-rw-r–r–. 1 root root 221 Jun 14 09:02 test2.txt
-rw-r–r–. 1 root root 221 Jun 14 09:03 test3.txt
-rw-r–r–. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
—————————–END OF OUTPUT———————————————
Format for doing the untar from the files: tar -xvf
—————————-OUTPUT——————————————————-
[root@kalwa2 zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Jun 14 09:02 test1.txt
-rw-r–r–. 1 root root 221 Jun 14 09:02 test2.txt
-rw-r–r–. 1 root root 221 Jun 14 09:03 test3.txt
-rw-r–r–. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]# rm -f *.txt
Note: Removing txt files for better understanding of the topic please do not perform this command in your environment.
[root@kalwa2 zip_test]# ll
total 12
-rw-r–r–. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
[root@kalwa2 zip_test]# tar -xvf test.tar
test1.txt
test2.txt
test3.txt
[root@kalwa2 zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Jun 14 09:02 test1.txt
-rw-r–r–. 1 root root 221 Jun 14 09:02 test2.txt
-rw-r–r–. 1 root root 221 Jun 14 09:03 test3.txt
-rw-r–r–. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
—————————–END OF OUTPUT———————————————
For checking the contents of the tar file use command tar -tvf
—————————-OUTPUT——————————————————-
[root@kalwa2 zip_test]# tar -tvf test.tar
-rw-r–r– root/root 221 2015-06-14 09:02 test1.txt
-rw-r–r– root/root 221 2015-06-14 09:02 test2.txt
-rw-r–r– root/root 221 2015-06-14 09:03 test3.txt
[root@kalwa2 zip_test]#
—————————–END OF OUTPUT———————————————
Leave a Reply