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.
compress [OPTION]... [FILE]...
- -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.
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.
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.