Monday 5 August 2019

Linux :: Compress,Uncompress command

compress – The compress utility will attempt to reduce the size of the named files. File will be replaced by one with the extension .Z, while keeping the same ownership modes, change times and modification times.

uncompress – The uncompress utility will restore files to their original state after they have been compressed using the compress utility.
SYNTAX:
compress [ -fv ] [ file … ]
uncompress [ -cfv ] [ file … ]
zcat [ file … ]
Options:
-c Write to the standard output. No files are changed.
-f When compressing, force compression of file, even if it does not actually reduce the size of the file, or if the corresponding file.Z file already exists.
-v Verbose. Write to standard error messages concerning the percentage reduction or expansion of each file.

gzip and gunzip command

gzip : The gzip utility will attempt to reduce the size of the named files. File will be replaced by one with the extension .gz, while keeping the same ownership modes, change times and modification times.
gunzip: The gunzip utility will restore files to their original state after they have been compressed using the gzip utility.

Difference between gzip and compress

Both the utlity compress and gzip compress the file i.e serve the same purpose
1) In general Compress will run faster and use less memory, but gzip will generally reach significantly higher levels of compression.
2) Compress is a old algorithm while gzip is the new one
Examples:
Compression
using compress
>ls
alert_CHECK.log
>compress alert_CHECK.log
> ls
alert_CHECK.log.Z
>ls
alert_CHECK.log
using gzip
>ls
alert_CHECK.log
>gzip alert_CHECK.log
> ls
alert_CHECK.log.gz
UnCompression
using uncompress
>ls
alert_CHECK.log.Z
>uncompress alert_CHECK.log.Z
> ls
alert_CHECK.log
>ls
alert_CHECK.log
using gunzip
>ls
alert_CHECK.log.gz
>gunzip alert_CHECK.log.gz
> ls
alert_CHECK.log
Fews things to note
1) when compress or uncompress we should have the disk space to hold both the compress and uncompress copy
2) if it fails,it get revert back to original status

0 comments:

Post a Comment