Linux gzip Command In Hindi

Blogs ❯❯ Linux

Image could not load

Image by pixabay

what is gzip Command ?

Linux में Gzip एक common compression algorithm है जो file को original file format, ownership और timeline के साथ compress करती है। जब किसी file or folder को gzip command से compress करते है। तो इसका same name पहले जैसा ही होता है लेकिन extension .gz हो जायेगा ।

gzip Syntax

$ gzip [options] file1 file2

gzip command के सभी options देखने के लिए gzip -h या gzip --help command कर सकते हैं।

$ gzip --help
  -c, --stdout      write on standard output, keep original files unchanged
  -d, --decompress  decompress
  -f, --force       force overwrite of output file and compress links
  -h, --help        give this help
  -k, --keep        keep (don't delete) input files
  -l, --list        list compressed file contents
  -L, --license     display software license
  -n, --no-name     do not save or restore the original name and timestamp
  -N, --name        save or restore the original name and timestamp
  -q, --quiet       suppress all warnings
  -r, --recursive   operate recursively on directories
      --rsyncable   make rsync-friendly archive
  -S, --suffix=SUF  use suffix SUF on compressed files
      --synchronous synchronous output (safer if system crashes, but slower)
  -t, --test        test compressed file integrity
  -v, --verbose     verbose mode
  -V, --version     display version number
  -1, --fast        compress faster
  -9, --best        compress better

Compress File Using .gz

by default , आप जो file pass करोगे उसी name से .gz file बन जाएगी। और सभी files delete हो जाएँगी। Example के लिए मेरी current directory में different - different size कई files और directories हैं , जिन्हे ls Command करके आप देख सकते हैं।

$ ls 
testfile1  testfile2  testfile3  testfile4

अब gzip command run करके देखते हैं -

$ gzip testfile1
$ ls
testfile1.gz  testfile2  testfile3  testfile4

Output में आप देख सकते हैं कि testfile1 file की जगह testfile1.gz बन गयी है।

Linux Compress multiple files

$ gzip testfile2 testfile3
$ ls
testfile1.gz  testfile2.gz  testfile3.gz 

Keep Original File

हालाँकि आप -k option का use करके file को delete होने से बचा सकते हैं।

$ gzip testfile4
$ ls
testfile1.gz  testfile2.gz  testfile3.gz testfile4 testfile4.gz
Compress Every File in a Folder and it's subfolder

ऊपर दिए गए सभी examples files के लिए थे , किसी directory के अंदर का सभी files / sub-directory को compress करने के लिए -r option का use किया जाता है।

$ gzip -r directory_name

Linux Decompress File Using .gz

same , gzip command का use करके आप किसी compressed file को decompress भी कर सकते हैं। decompress करने के लिए -d option का use किया जाता है।

$ gzip -d testfile1

Linux Decompress Multiple Files

ठीक multiple files compression की तरह ही आप एक साथ कई files भी decompress कर सकते हैं।

$ gzip -d testfile2.gz testfile3.gz testfile4.gz
$ ls
testfile1  testfile2  testfile3 testfile4

List the Content of the Compressed File

-l option का use करके आप किसी compressed file का content भी देख सकते हैं।

$ gzip -l testfile1.gz
compressed        uncompressed  ratio uncompressed_name
                 30                   0   0.0% testfile1
Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook