gzip yes linux Common compression in / Decompression tool , The most common use object is *.gz Format file , Here is a brief introduction to its most common usage ,

GZIP(1) General Commands Manual GZIP(1)

NAME
     gzip, gunzip, zcat - compress or expand files

SYNOPSIS
     gzip [ -acdfhklLnNrtvV19 ] [--rsyncable] [-S suffix] [ name ... ]
     gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ... ]
     zcat [ -fhLV ] [ name ... ]

OPTIONS
     -c --stdout --to-stdout Write results to standard output , The original document remains unchanged
     -d --decompress --uncompress decompression
     -k --keep During compression or decompression , Keep original file
     -r --recursive
     -t --test Check the integrity of the compressed file
     -v --verbose Displays the name and compression rate of each file
     -# --fast --best Value from -1( Fastest ) reach -9( best ), The default is -6

Example 1, Compressed file
The original file name is file1.txt, The original file disappears after compression , The compressed file name is file1.txt.gz
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 12383865 Aug 21 08:08 file1.txt
root@ubuntu:/tmp# gzip file1.txt
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz

Example 2, Unzip file
root@ubuntu:/tmp# gzip -d file1.txt.gz
root@ubuntu:/tmp# ls -lh file1.*
-rw-r--r-- 1 root root 12M Aug 21 08:08 file1.txt

Example 3, When compressing , Display compression ratio
root@ubuntu:/tmp# gzip -v file1.txt
file1.txt: 98.9% -- replaced with file1.txt.gz

Example 4, Compress multiple files with one command , After compression , They are separate :
root@ubuntu:/tmp# gzip file1.txt file2.txt
root@ubuntu:/tmp# ls -l
total 1348
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz
-rw-r--r-- 1 root root 392 Aug 21 08:15 file2.txt.gz

Example 5, During compression , Keep original file
root@ubuntu:/tmp# gzip -k file1.txt
root@ubuntu:/tmp# ls file1.*
file1.txt file1.txt.gz

Example 6, Compress to standard output
You can connect two files
root@ubuntu:/tmp# cat file1.txt file2.txt | gzip > foo.gz
perhaps
root@ubuntu:/tmp# gzip -c file1.txt file2.txt > foo.gz
======================================

gzip
The compressed format is :*.gz

This compression method cannot save the original file ; And the directory cannot be compressed

Command example :
# compress
[root@localhost tmp]# gzip buodo
[root@localhost tmp]# ls
buodo.gz
# decompression
[root@localhost tmp]# gunzip buodo.gz 
[root@localhost tmp]# ls
buodo

tar
Command options :
    -z(gzip)       use gzip To compress / Unzip file
    -j(bzip2)     use bzip2 To compress / Unzip file
    -v(verbose)   Detailed report tar Processed file information
    -c(create)     Create a new profile
    -x(extract)   Unzip files or directories
    -f(file)       Use of archives or equipment , This option is usually required .

Command example :
# compress
[root@localhost tmp]# tar -zvcf buodo.tar.gz buodo
[root@localhost tmp]# tar -jvcf buodo.tar.bz2 buodo 

# decompression
[root@localhost tmp]# tar -zvxf buodo.tar.gz 
[root@localhost tmp]# tar -jvxf buodo.tar.bz2

zip
And gzip comparison :1) You can compress directories ; 2) You can keep the original file ;

option :

    -r(recursive)     Recursively compress all files and directories in the directory

Command example :
# Compress and unzip files
[root@localhost tmp]# zip boduo.zip boduo
[root@localhost tmp]# unzip boduo.zip

# Compress and unzip directories
[root@localhost tmp]# zip -r Demo.zip Demo
  adding: Demo/ (stored 0%)
  adding: Demo/Test2/ (stored 0%)
  adding: Demo/Test1/ (stored 0%)
  adding: Demo/Test1/test4 (stored 0%)
  adding: Demo/test3 (stored 0%)
[root@localhost tmp]# unzip Demo.zip 
Archive:  Demo.zip
   creating: Demo/
   creating: Demo/Test2/
   creating: Demo/Test1/
 extracting: Demo/Test1/test4        
 extracting: Demo/test3  

bzip2
Compressed format :.bz2
parameter
    -k     Retain the original file after generating the compressed file

Command example
# compress
[root@localhost tmp]# bzip2 boduo
[root@localhost tmp]# bzip2 -k boduo

# decompression
[root@localhost tmp]# bunzip2 boduo.bz2 

Technology
©2019-2020 Toolsou All rights reserved,
Android Using wechat in H5 Payment result refresh during payment shock !!C++ Can make a sound ! Basic operation of single linked list C Language explanation Java Implement an epidemic number management system 2021 year 11 World programming language ranking linux upper mysql Invalid command _linux lower mysql The command is useless Java project : Campus dormitory management system (java+jsp+javaweb+mysql+ajax) Wechat applet development project directory linux ubuntu Which version ,Ubuntu Which version is the best ?python Code painting cherry blossoms - How to use Python Draw a beautiful cherry blossom