{"id":7204,"date":"2018-11-06T16:53:00","date_gmt":"2018-11-06T13:53:00","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-znew-command\/"},"modified":"2018-11-06T16:53:00","modified_gmt":"2018-11-06T13:53:00","slug":"linux-znew-command-tutorial-for-beginners-with-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-znew-command-tutorial-for-beginners-with-examples\/","title":{"rendered":"Linux znew Command Tutorial for Beginners (with Examples)"},"content":{"rendered":"<p>Did you know Linux offers a way to recompress .Z files to .gz files? Yes, the znew command lets you do this. In this tutorial, we will discuss the basics of this command line utility using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.<\/p>\n<h2 id=\"linux-znew-command\">Linux znew command<\/h2>\n<p>As already mentioned above, the znew command in Linux lets you convert .Z files to .gz type by recompressing them. Following is its syntax:<\/p>\n<p class=\"command\">znew [ -ftv9PK] [ name.Z &#8230;\u00a0 ]<\/p>\n<p>And here&#8217;s what the man page says about this command:<\/p>\n<pre readability=\"7\">Znew recompresses\u00a0 files from .Z (compress) format to .gz (gzip) format.\u00a0 <p>If you want to recompress a file already in gzip format, rename the file to force a .Z extension <br\/>then apply znew.<\/p><\/pre>\n<p>Following are some Q&amp;A styled examples that should give you a better idea on how the znew command works.<\/p>\n<h2 id=\"q-how-to-use-the-znew-command\">Q1. How to use the znew command?<\/h2>\n<p>It&#8217;s fairly simple &#8211; just provide the .Z file name as input. Here&#8217;s an example:<\/p>\n<p class=\"command\">znew files2.Z<\/p>\n<p>This command produces &#8216;files2.gz&#8217; in the output, removing the original .Z file in the process.<\/p>\n<h2 id=\"q-what-if-a-gz-file-of-same-name-already-exists\">Q2. What if a .gz file of same name already exists?<\/h2>\n<p>If a .gz file with the same name already exists in your current working directory, the znew command will ask to confirm whether or not you want to overwrite it.<\/p>\n<p>For example, in my case, the following command:<\/p>\n<p class=\"command\">znew files2.Z<\/p>\n<p>produced the following confirmation prompt:<\/p>\n<pre>gzip: files2.gz already exists; do you wish to overwrite (y or n)?<\/pre>\n<p>So you can press &#8216;y&#8217; if you want to move ahead, else press &#8216;n&#8217;. Alternatively, you can also use the -f command line option to force recompression from .Z to .gz format if a .gz file already exists.<\/p>\n<h2 id=\"q-how-to-make-znew-display-details-in-output\">Q3. How to make znew display details in output?<\/h2>\n<p>The -v command line option allows znew to display details like the name and percentage reduction for each file compressed. Here&#8217;s an example:<\/p>\n<p><a class=\"fancybox\" id=\"img-znew-v\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/znew-v.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples.png\" alt=\"znew verbose output\" width=\"381\" height=\"40\" title=\"\"><\/a><\/p>\n<h2 id=\"q-what-are-other-useful-znew-options\">Q4. What are other useful znew options?<\/h2>\n<p>There are a handful. Like -t tests the new files before deleting originals, -9 makes sure the tool uses the slowest compression method (optimal compression), and -P makes sure znew uses pipes for the conversion to reduce disk space usage.<\/p>\n<p>Following is the complete list of options znew offers:<\/p>\n<pre readability=\"14\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -f\u00a0\u00a0\u00a0\u00a0 Force recompression from .Z to .gz format even if a .gz file already exists.<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -t\u00a0\u00a0\u00a0\u00a0 Tests the new files before deleting originals.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -v\u00a0\u00a0\u00a0\u00a0 Verbose. Display the name and percentage reduction for each file compressed.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -9\u00a0\u00a0\u00a0\u00a0 Use the slowest compression method (optimal compression).<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -P\u00a0\u00a0\u00a0\u00a0 Use pipes for the conversion to reduce disk space usage.<\/p><p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -K\u00a0\u00a0\u00a0\u00a0 Keep a .Z file when it is smaller than the .gz file; implies -t.<\/p><\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>If your work involves compressing and decompressing files through the Linux command line, the znew command may be useful to you. In this tutorial, we discussed some key options znew offers. For more info, head to the tool&#8217;s <a href=\"https:\/\/linux.die.net\/man\/1\/znew\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a>.<\/p>\n<div class=\"authorbox\" readability=\"15\">\n<img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples.jpg\" alt=\"Himanshu Arora\" title=\"\"> <\/p>\n<p><strong>About Himanshu Arora<\/strong><\/p>\n<p>Himanshu Arora has been working on Linux since 2007. He carries professional experience in system level programming, networking protocols, and command line. In addition to HowtoForge, Himanshu&#8217;s work has also been featured in some of world&#8217;s other leading publications including Computerworld, IBM DeveloperWorks, and Linux Journal.<\/p>\n<\/div>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-znew-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples-1.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-znew-command%2F&amp;text=Linux+znew+Command+Tutorial+for+Beginners+%28with+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples-2.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-znew-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/linux-znew-command-tutorial-for-beginners-with-examples-4.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Did you know Linux offers a way to recompress .Z files to .gz files? Yes, the znew command lets you do this. In this tutorial, we will discuss the basics of this command line utility using some easy to understand examples. But before we do that, it&#8217;s worth mentioning that all examples here have been [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-7204","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/7204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=7204"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/7204\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=7204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=7204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=7204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}