1, the preface

Zip, unzip, and tar are commonly used to compress and transfer files in o&M. This section describes the tar command

2. Code implementation

 

The tar parameters:

-c: create Specifies the parameter for creating compressed files. -x: decompresses the parameters of the compressed file. -z: Indicates whether gzip compression is required. -v: displays files during compression. -f: indicates the top document name, followed by the file name immediately after f. No parameter can be added

Examples of usage:

1. Package all files in the entire Photo directory as photo.tar

tar -cvf photo.tar photo Pack only, not compress
tar -zcvf photo.tar.gz photo After packaging, compress with gzip
Copy the code

2. Decompress the TGZ file to the specified directory tar ZXVF aaa. TGZ -c specified directory for example, decompress the aaa

tar zxvf aaa.tgz -C aaa
Copy the code