• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Unix command and scripts » Compress And Uncompress in Linux

Compress And Uncompress in Linux

June 29, 2020 by techgoeasy Leave a Comment

In continuation of our series of Linux tutorial,I am here presenting the Compress and Uncompress command in 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 ... ]

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.

Few 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

Compression
$ls
alert_CHECK.log
$compress alert_CHECK.log
$ ls
alert_CHECK.log.Z 
Uncompression
$ls
alert_CHECK.log.Z
$uncompress alert_CHECK.log.Z
$ ls
alert_CHECK.log 
 

We can use compress command to compress the tar file directory using PIPE also. Example shown below

tar compress directory command

tar -cvf - dir1 dir2 | compress > file.tar.Z
tar compress directory command

Similarly , we can use uncompress to uncompress the tar file using PIPE command.Example shown below

Uncompress will go like

uncompress -c file.tar.Z|tar -xvf  -
tar uncompress directory command

Also Read
awk command : Awk command in Unix or Linux is a powerful command for processing text. Learn about awk syntax, records, fields, line Separator with examples of awk in unix
split command
find command : find command in Unix with example,How to use find command in Unix.Unix find directory command,how to find find based on modified time
tr command in Unix : check out about tr command in Unix operating system , where all we can use and what all options are available in Linux/Unix
gzip and gunzip command in Linux
tee command in Unix

Filed Under: Unix command and scripts Tagged With: Compress, gzip and gunzip command, Uncompress command

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to generate sql monitor report in Oracle
  • How to find the long running (longops session) in Oracle
  • How to find concurrent request id from Sid or spid
  • how to check recycle bin in oracle: Purge, enable/disable
  • how to check fra size in oracle: Location, usage, change size

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us