English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux reference manual

Linux Command大全

Linux gzip command

The Linux gzip command is used to compress files.

gzip is a widely used compression program, and the compressed files will have the extension ".gz" added to their names.

Syntax-fast][file...] or gzip [-acdfhlLnNqrtvV][-S <compressed string>][--<compression efficiency>][/gzip [-fast][file...] or gzip [-acdfhlLnNqrtvV][-S <compressed string>][--<compression efficiency>][/best

fast][directory]Parameters

  • -:--ascii Use ASCII text mode.
  • -c or--stdout or--to-stdout Output the compressed file to the standard output device without modifying the original file.
  • -d or--decompress or----uncompress Uncompress the compressed file.
  • -f or--force Force to compress files. Ignore whether the file name or hard link exists and whether the file is a symbolic link.
  • -h or--help Online help.
  • -l or--list List the relevant information of the compressed file.
  • -L or--license Display version and copyright information.
  • -n or--no-name Do not save the original file name and timestamp when compressing files.
  • -N or--name Save the original file name and timestamp when compressing files.
  • -q or--quiet Do not display warning messages.
  • -r or--recursive Recursively process all files and subdirectories in the specified directory.
  • -S <compressed string> or----suffix <compressed string> Change the compressed string.
  • -t--test  Test whether the compressed file is correct and error-free.
  • -vor--verbose  Display the execution process of the command.
  • -Vor--version  Display version information.
  • -<Compression Efficiency>  Compression efficiency is a value between1-9The default value is6,the larger the specified value, the higher the compression efficiency will be.
  • --best  This parameter's effect is similar to specifying-9"Parameters are the same.
  • --fast  This parameter's effect is similar to specifying-1"Parameters are the same.

Online Examples

Compress files

[[email protected] a]# ls //Display current directory files
a.c b.h d.cpp
[[email protected] a]# gzip * //Compress all files in the directory
[[email protected] a]# ls //Display current directory files
a.c.gz    b.h.gz    d.cpp.gz
[[email protected] a]# 

Next example1List detailed information

[[email protected] a]# gzip -dv * //Uncompress files and list detailed information
a.c.gz:     0.0% -- replaced with a.c
b.h.gz:     0.0% -- replaced with b.h
d.cpp.gz:     0.0% -- replaced with d.cpp
[[email protected] a]# 

Next example1Display information of compressed files

[[email protected] a]# gzip -l *
     compressed    uncompressed ratio uncompressed_name
         24          0  0.0% a.c
         24          0  0.0% b.h
         26          0  0.0% d.cpp

Linux Command大全