Compression command:
tar.gz format: TAR-ZCVF custom compressed file name. tar.gz Compressed file name
Zip Format: Zip-r custom compressed file name. zip Compressed file name
If you want to compress the entire folder, you can also go to the directory where you want to compress the folder, and then run the TAR-ZCVF custom compressed file name. tar.gz *
Zip-r a custom compressed file name. zip *
Decompression command:
tar.gz format: TAR-ZXVF compressed file name. tar.gz
ZIP Format: Unzip compressed file name. zip
The unzipped file can only be placed in the current directory.
To exclude a file or folder method from a compressed file:
Many times we need to package a directory, and there are dozens of subdirectories and sub-files in this directory, we need to exclude one or two directories or a few files when we pack.
At this time we are packing with the tar command, add parameter --exclude can achieve the purpose.
We take myweb as an example, when packaging we want to exclude the myweb/logs directory, the command is as follows:
TAR-ZCVF myweb.tar.gz --exclude=myweb/logs myweb
If you want to exclude more than one directory, add--exclude, such as we want to exclude logs and libs two directories and file Readme.txt, the command is as follows:
TAR-ZCVF myweb.tar.gz --exclude=myweb/logs--exclude=myweb/libs--exclude=myweb/readme.txt myweb
It is important to note that when we use the tar--exclude command to exclude packaging, we cannot add "/", otherwise the logs directory and the files under it will be packaged in, for example:
TAR-ZCVF myweb.tar.gz--exclude=myweb/logs/ --exclude=myweb/libs/ MyWeb (This is the wrong wording)
TAR-ZCVF myweb.tar.gz--exclude=myweb/logs--exclude=myweb/libs myweb (This is the correct notation)
Common compression and decompression methods under Linux