Linux compress command
- What you learn is not just technology, but also dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Linux Tutorial
- Linux Tutorial
- Linux Introduction
- Linux Installation
- Linux Cloud Server
- Install Linux with WSL
- Linux System Boot Process
- Linux System Directory Structure
- Solution for Forgetting Linux Password
- Linux Remote Login
- Linux File Basic Attributes
- Linux File and Directory Management
- Linux User and User Group Management
- Linux Disk Management
- Linux vi/vim
- Linux yum command
- Linux apt command
Shell Tutorial
- Shell Tutorial
- Shell Variables
- Shell Passing Arguments
- Shell Arrays
- Shell Operators
- Shell echo command
- Shell printf command
- Shell test command
- Shell Process Control
- Shell Functions
- Shell Input/Output Redirection
- Shell File Inclusion
Linux Reference Manual
- Linux Command Manual
- Nginx Installation and Configuration
- MySQL Installation and Configuration
- Linux Quiz
Nginx Installation and Configuration
Linux compress command
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/
YouTip