Linux/Unix Tutorial for Beginners for tar command

Veröffentlicht am: 29 Mai 2019
auf dem Kanal: Coding GuruJi
103
3

This tutorial comprises of brief description with real time output of various options of the "tar" command of UNIX.

The various combinations of tar command are as follows :-

1.) Create tar archive file
tar -cvf test.tar /test/
2.) Create tar.gz archive file
tar -cvzf test.tar.gz /test/
3.) Create tar.bz2 archive file
tar -cvfj test.tar.bz2 /test/

4.) Untar a tar archive file in current directory
tar -xvf test.tar
5.) Untar a tar.gz archive file in current directory
tar -xvf test.tar.gz
6.) Untar a tar.bz2 archive file in current directory
tar -xvf test.tar.bz2

7.) List contents of a tar archive file
tar -tvf test.tar
8.) List contents of a tar.gz archive file
tar -tvf test.tar.gz
9.) List contents of a tar.bz2 archive file
tar -tvf test.tar.bz2

10.) Untar single file from a tar file
tar -xvf test.tar test_code.java
11.) Untar single file from a tar,gz file
tar -zxvf test.tar.gz test_code.java
12.) Untar multiple files from tar, tar.gz and tar.bz2 file :-
tar -xvf test.tar "file_1" "file_2"
tar -zxvf test.tar.gz "file_1" "file_2"
tar -jxvf test.tar.bz2 "file_1" file_2"
13.) Extract group of files using wildcard
tar -xvf test.tar --wildcards "*.java"
tar -zxvf test.tar.gz --wildcards "*.java"
tar -jxvf test.tar.bz2 --wildcards "*.java"
14.) Add files or directories to tar archive file
tar -rvf test.tar temp
N.B- The tar -rvf options works only for .tar files and will show errors for .tar.gz and .tar.bz2

15.) To check the size of a tar, tar.gz, tar.bz2 archive file
tar -czf - test.tar | wc -c

16. ) To create a tar.gz file file with destination path on a different machine or server
tar zcvf - test | ssh root@192.168.0.4 "cat greater_than_sign /tempo/testing.tar.gz"
17.) To untar a tar.gz file to a different destination machine or server.
cat testing.tar.gz | ssh root@192.168.0.4 "cd /test/; tar zxvf -"

Please ignore in case of a typo in the description part and refer to the video..
:)


Auf dieser Seite können Sie das Online-Video Linux/Unix Tutorial for Beginners for tar command mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding GuruJi 29 Mai 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 103 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!