YouTip LogoYouTip

Linux Comm Compress

Linux compress command

Linux compress command

- What you learn is not just technology, but also dreams!

Linux Tutorial

Shell Tutorial

Linux Reference Manual

Shell File Inclusion

Nginx Installation and Configuration

Linux compress command

Image 3: Linux Command Manual Linux Command Manual

The Linux compress command is a quite old Unix file compression utility. Compressed files are given a .Z extension to distinguish them from uncompressed files. Compressed files can be decompressed with uncompress. To compress multiple files into a single archive, you must first tar them and then compress. Since gzip can produce better compression ratios, most people have switched to using gzip as their file compression tool.

Syntax

compress [file ...]

Parameters:

  • c Output result to standard output device (usually the screen)
  • f Force writing to file. If the destination file already exists, it will be overwritten (force)
  • v Print program execution messages on the screen (verbose)
  • b Set the upper limit of the common string count, calculated in bits. The value that can be set ranges from 9 to 16 bits. Since a larger value means more common strings can be used, resulting in a higher compression ratio, the default value of 16 bits is generally used (bits)
  • d Decompress the compressed file
  • List version information

Examples:

  • Compress source.dat into source.dat.Z. If source.dat.Z already exists, its content will be overwritten by the compressed file.
    compress -f source.dat
  • Compress source.dat into source.dat.Z and print the compression ratio.
    -v and -f can be used together
    compress -vf source.dat
  • Output the compressed data and then redirect it to target.dat.Z to change the compressed file name.
    compress -c source.dat > target.dat.Z
  • A larger value for -b results in a higher compression ratio. The range is 9-16, and the default is 16.
    compress -b 12 source.dat
  • Decompress source.dat.Z into source.dat. If the file already exists, the user must press y to confirm overwriting. If using -df, the program will automatically overwrite the file. Since the system automatically adds .Z as the extension, source.dat will be automatically treated as source.dat.Z.
    compress -d source.dat
    compress -d source.dat.Z

Compress a file

[root@.com ~]# compress abc.h
[root@.com ~]# ls abc.h.Z

Decompress a file

[root@.com ~]# compress -d abc.h.Z
[root@.com ~]# ls abc.h.

Compress with a specified compression ratio

[root@.com ~]# compress -b 7 abc.h

Force compress a folder

[root@.com ~]# compress -rf /home/abc/ 

Image 4: Linux Command Manual Linux Command Manual

← Os ChownOs Lchown β†’