Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

compress command in Linux with examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

compress command is used to reduce the file size. After compression, the file will be available with an added .Z extension. File permissions will still remain the same as before using compress command. This command uses the adaptive Lempel-Ziv coding and it ignores the symbolic links. And also this command is part of ncompress package, which contains utilities for fast compression and decompression.

Note: If no files are specified then the standard input is compressed to the standard output.

Syntax:

compress [OPTION]... [FILE]...

Options:

  • -v Option: It is used to print the percentage reduction of each file. This option is ignored if the -c option is also used. Compress example.xls and rename that file to example.xls.Z with a percentage reduction of 70.41%.
    compress -v example.xls
    

  • -c Option: Compressed or uncompressed output is written to the standard output. No files are modified. The -v option is ignored. Compression is attempted even if the results will be larger than the original.

    Example:

    compress -c example.xls > new.Z
    

  • -r Option: This will compress all the files in the given directory and sub-directories recursively. It is helpful to combine the -r option with -v to see exactly what the command is doing.

    Example:

    compress -rv abc
    

    This will compress all the files within abc.

  • -f Option: This will compress files without any guarantee of size reduction, meaning it will compress files even if the file size is not reduced.
    compress -f asc.txt
    

    This will convert asc.txt into asc.txt.Z but size reduction is not assured.

My Personal Notes arrow_drop_up
Last Updated : 15 May, 2019
Like Article
Save Article
Similar Reads
Related Tutorials