Refer to "Linux Shell Script Introduction Second Edition"
The-C in the TAR command stands for "Create file"
The-F in the tar command represents "specify filename". (the file name must be immediately after-F, and-F should be the last one in the option)
1. Archive Files with tar:
[Email protected]:~$ tar-cf All.tar all all~[email protected]:~$
2, use the-t option to view the files contained in the archive file:
[Email protected]:~$ tar-tf all.tarallall~[email protected]:~$
3, use the-V or-VV parameter to learn more details when archiving or listing the list of archived files (this feature is called "verbose mode verbose"):
[Email protected]:~$ tar-tvf all.tar-rw-rw-r--ubuntu/ubuntu 10240 2015-06-29 20:24 all-rw-rw-r--ubuntu/ubuntu 1 20 15-06-29 12:27 All~[email protected]:~$
4. Add files to the archive file:
[Email protected]:~$ tar-rvf all.tar argsargs[email protected]:~$ tar-tf all.tarallall~args[email protected]:~$
5, option-XF is extracted from the contents of the archive file into the current directory:
6, option-C is used to create a file that needs to be extracted to that directory:
[Email protected]:~$ mkdir dir[email protected]:~$ tar-xvf all.tar-c dirallall~args[email protected]:~$ cd Dir[email Pro tected]:~/dir$ lsall all~ args[email protected]:~/dir$
Gzip can only compress a single file or data stream, and cannot archive directories and multiple files, so we need to create a tar archive before compressing it with Gzip.
7,gzip Compressed Files:
[Email protected]:~$ gzip all.tar[email protected]:~$ ls-l all.tar.gz-rw-rw-r--1 ubuntu ubuntu 207 June-20:59 All.tar. Gz
8, unzip the gzip:
[Email protected]:~$ gunzip all.tar.gz
9,zip Compressed Files:
[Email protected]:~$ zip all.tar.zip all.tar Adding:all.tar (deflated 99%)
10:zip to recursively manipulate directories and files:
[Email protected]:~$ zip-r dir.zip dir adding:dir/(stored 0) adding:dir/all~ (stored 0) Adding:dir/all (deflated 99%) Adding:dir/args (deflated 6) [email protected]:~$
11,unzip extract the contents from the zip file:
[Email protected]:~$ unzip dir.ziparchive: dir.zip creating:dir/extracting:dir/all~ inflating:dir/all Inflating:dir/args
Tar&&gzip&&zip