Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

How to compress and decompress a file in the terminal

gzip <filename>

# command to compress a file while keeping the original file
gzip -c <filename> > <filename.gz>
# OR
gzip -k <filename>

# command to uncompress a file
gunzip <filename.gz>
# OR
gzip -d <filename.gz>
# OR
zcat <filename.gz>

# -f is used to force compress or decompress
gzip -cf <filename>

# -q supresses all warnings

# -r recursively compresses all the files within a specified directory
gzip -r Documents

# flags to alter the speed and rate of compression
--fast or -1 speeds up the process and results to a lesser compression
--best or -9 is the slowest and give the best compression
-6 is the default

# check out man gzip for more details o compressing several files at once.
 
PREVIOUS NEXT
Tagged: #How #compress #decompress #file #terminal
ADD COMMENT
Topic
Name
3+3 =