{"id":5636,"date":"2018-12-11T17:04:43","date_gmt":"2018-12-11T17:04:43","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=5636"},"modified":"2018-12-28T20:18:57","modified_gmt":"2018-12-28T20:18:57","slug":"guide-to-learn-linux-gunzip-command-with-examples","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/11\/guide-to-learn-linux-gunzip-command-with-examples\/","title":{"rendered":"Guide to Learn Linux gunzip Command with Examples"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/12\/gunzip.png\" alt=\"gunzip command\" width=\"713\" height=\"341\" \/><\/p>\n<p>Have you come across files bearing a .gz extension? These are files which have been compressed using the gzip command. Gunzip is a Linux command that is used to decompress such files earing the .gz extension and in this tutorial, we will look at different usages of the Gunzip command.<\/p>\n<p>But first, let&#8217;s compress a file using the gzip command. The syntax will be as follows<\/p>\n<p># gzip file_name<\/p>\n<p>When you verify the file using the <a href=\"https:\/\/linoxide.com\/linux-command\/20-ls-command-linux\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>, you will notice the presence of another file with the same file name but with a .gz extension.<\/p>\n<p>Output<\/p>\n<p># file_name.gz<\/p>\n<p>Let&#8217;s now see how we can decompress files.<\/p>\n<h2>1) Decompress files using the Gzip Command<\/h2>\n<p>In addition to compressing files, the gzip command can also be used to decompress files. The syntax for decompressing a file is<\/p>\n<p># gzip -d file_name.gz<\/p>\n<p>Output<\/p>\n<p># file_name<\/p>\n<p>To decompress files recursively in a folder add the -r flag as shown<\/p>\n<p># gzip -dr folder_name<\/p>\n<h2>2) Decompress files using the Gunzip Command<\/h2>\n<p>While the gzip command also comes in handy in compressing and decompressing files, Gunzip command is another command that allows you to decompress files in a very simple way that&#8217;s easy to remember. The syntax is<\/p>\n<p># gunzip file_name.gz<\/p>\n<p>Output<\/p>\n<p># file_name<\/p>\n<p>Once gunzip decompresses a file, the extension is removed. The file <em>file_name.gz<\/em> changes to <em>file_name <\/em>and is expanded to the maximum size.<\/p>\n<h2>3) Display verbose output of decompression<\/h2>\n<p>To display verbose output, append the -v flag as shown<\/p>\n<p># gunzip -v file_name.gz<\/p>\n<p>Output<\/p>\n<p>test_file.gz: 52.1% &#8212; replaced with test_file<\/p>\n<h2>4) Keep both the compressed file and the decompressed one<\/h2>\n<p>To keep both copies of the compressed and decompressed file run<\/p>\n<p># gunzip -k file_name.gz<\/p>\n<p>You will now have two files, filename &amp; filename.gz<\/p>\n<p>Output<\/p>\n<p>file_name.gz file_name<\/p>\n<h2>5) Display the output of the compressed file without first decompressing<\/h2>\n<p>To print out the output of the compressed file before decompressing it run<\/p>\n<p># gunzip -c file_name.gz<\/p>\n<h2>6) To display more information about a compressed file<\/h2>\n<p>To get more information about the compressed file run<\/p>\n<p># gunzip -l file_name.gz<\/p>\n<p>The output of the command above command will give the following values<\/p>\n<ul>\n<li>Compressed size<\/li>\n<li>Uncompressed size<\/li>\n<li>Ratio of compression<\/li>\n<li>Uncompressed name<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linoxide.com\/wp-content\/uploads\/2018\/11\/gunzip_output.png\" alt=\"Gunzip Command\" width=\"544\" height=\"35\" \/><\/p>\n<p>This information comes in handy when dealing with large file sizes, especially when you are running low on disk space. You wouldn&#8217;t want to carelessly uncompress large files lest they eat up your remaining disk space.<\/p>\n<h2>7) To decompress lot&#8217;s of files recursively<\/h2>\n<p>To achieve this, run<\/p>\n<p># gunzip -r folder_name<\/p>\n<p>Let&#8217;s assume you have a folder structure like below where Office_files is the main folder containing zipped files sales.gz and marketing.gz plus another folder 2018 report with other zipped files.<\/p>\n<p>office_files<\/p>\n<p>sales.gz<\/p>\n<p>marketing.gz<\/p>\n<p>2018 Report<\/p>\n<p>first_quarter_report.gz<\/p>\n<p>second_quarter_report.gz<\/p>\n<p>third_quarter_report.gz<\/p>\n<p>last_quarter_report.gz<\/p>\n<h2>8) To decompress all the files within a directory<\/h2>\n<p>Run below command to decompress all of the files in the directory.<\/p>\n<p># gunzip -r office_files<\/p>\n<h2>9) Test whether a compressed file is a valid file compressed using gzip<\/h2>\n<p>To do this, run<\/p>\n<p># gunzip -t file_name.gz<\/p>\n<p>If the file is invalid, you&#8217;ll get a warning but if it&#8217;s valid, nothing will be printed on the screen and you&#8217;ll be taken back to the shell.<\/p>\n<h3>Read Also:<\/h3>\n<ul>\n<li><a href=\"https:\/\/linoxide.com\/how-tos\/7zip-linux-command-line\/\" target=\"_blank\" rel=\"noopener\">How To Use 7zip Archiver On Linux Command Line<\/a><\/li>\n<li><a href=\"https:\/\/linoxide.com\/linux-command\/best-compression-with-zip-command\/\" target=\"_blank\" rel=\"noopener\">20 Examples for Linux Zip and UnZip Command<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/linoxide.com\/linux-command\/how-use-linux-gunzip-command-examples\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you come across files bearing a .gz extension? These are files which have been compressed using the gzip command. Gunzip is a Linux command that is used to decompress such files earing the .gz extension and in this tutorial, we will look at different usages of the Gunzip command. But first, let&#8217;s compress a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/11\/guide-to-learn-linux-gunzip-command-with-examples\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Guide to Learn Linux gunzip Command with Examples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5636","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/5636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=5636"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/5636\/revisions"}],"predecessor-version":[{"id":6261,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/5636\/revisions\/6261"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=5636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=5636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=5636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}