{"id":1717,"date":"2012-11-22T10:24:02","date_gmt":"2012-11-22T02:24:02","guid":{"rendered":"http:\/\/rmohan.com\/?p=1717"},"modified":"2012-11-22T10:24:02","modified_gmt":"2012-11-22T02:24:02","slug":"gzip-command","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1717","title":{"rendered":"GZIP COMMAND"},"content":{"rendered":"<p>Gzip is one of the frequent command used in linux . gzip command is use do to compression of a file for reducing size of file. This will saves the bandwidth if the file is transferring between different systems.Moreover the reduced size depends on the the content of the file, if the content is text, it will reduce 60% and for image, it should be 80%.<\/p>\n<p>gzip linux command usage<\/p>\n<p>if we want to copy the mulitple files,the files should becompressed, so that bandwidth of file is reduced.Gzip abbrivated as GUN zip<\/p>\n<p>Gzip command examples:-<\/p>\n<p>1.Compression the file with deleting original file.<\/p>\n<p>Gzip linuxFileName<\/p>\n<p>This will replace a linuxFileName.gz which has size of 80% of linuxFileName in the current directory. The filename size is reduced by this command. Once gz file is created, linuxFileName should be deleted<\/p>\n<p>2.Compression the file with keeping original file.<\/p>\n<p>Gzip \u2013c\u00a0 linuxFileName<\/p>\n<p>This command will behave same expect deleting the original file. So original file should be kept as it is.<br \/>2. Uncompress\/decompress the gz file<\/p>\n<p>Gunzip fileName.gz<\/p>\n<p>This will unzip the filename.gz and get the original file before using gzip command<\/p>\n<p>3.Compression multiple files in a directory<\/p>\n<p>Gzip -r directoryname<\/p>\n<p>using -r option, recursively traverse all the files, meaning all the files in current directory including all the files subdirectory and create a directoryname.gz which contains all the files in the current directory and subdirectory<br \/>After compression, total size of the files is approximately 20% less gz file.<\/p>\n<p>3. Uncompress\/decompress the gz file into multiple files<\/p>\n<p>Gunzip -r fileName.gz<\/p>\n<p>This will unzip the filename.gz into the the multiple original files before using gzip -r command<\/p>\n<p>4.Compression files fastly:-<\/p>\n<p>Gzip -1 filename.txt<br \/>Gzip \u2013fast filename.txt<\/p>\n<p>The both above options compress filename.txt very fast and create filename.txt.gz folder<\/p>\n<p>5.Compression files fastly:-<\/p>\n<p>Gzip -9 filename.txt<br \/>Gzip \u2013best filename.txt<\/p>\n<p>The both above options compress filename.txt files slowly and create filename.txt.gz folder<\/p>\n<p>Advanced gzip examples:-<\/p>\n<p>6.zip each file in the current directory and creating separate gz<\/p>\n<p>for filename in *.txt; do gzip -c &#8220;$filename&#8221; &gt; &#8220;$filename.gz&#8221;; <\/p>\n<p>let us say we have file1.txt,file2.txt,file3.txt in the current directory \/tmp\/directory. To do this, we have to iterate each file and do the gzip command redirect(&gt;) the output as gz file<br \/>The above command create file1.txt.gz,file2.txt.gz,file3.txt.gz<br \/>-c option keep all the original files (file1.txt,file2.txt,file3.txt) and give the file to stdout console.<br \/>if we don&#8217;t specified any option, it will remove all the files, and create a gz file<\/p>\n<p>Hope you got basic start for gzip with examples.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gzip is one of the frequent command used in linux . gzip command is use do to compression of a file for reducing size of file. This will saves the bandwidth if the file is transferring between different systems.Moreover the reduced size depends on the the content of the file, if the content is text, [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1717"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1717"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1717\/revisions"}],"predecessor-version":[{"id":1719,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1717\/revisions\/1719"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}