{"id":2569,"date":"2021-03-18T06:37:06","date_gmt":"2021-03-18T06:37:06","guid":{"rendered":"https:\/\/www.arzhost.com\/?p=1769"},"modified":"2024-10-16T19:58:56","modified_gmt":"2024-10-16T14:58:56","slug":"how-to-zip-a-directory-in-unix","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/","title":{"rendered":"how to zip a directory in unix"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#Introduction_to_Zipping_a_Directory_and_Using_UNIX\" >Introduction to Zipping a Directory and Using UNIX<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#How_to_zip_folder_using_the_zip_command_in_UNIX\" >How to zip folder using the zip command in UNIX:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#Boost_Your_Sites_Performance_with_VPS_Hosting_%E2%80%93_Best_Plans_Available\" >Boost Your Site\u2019s Performance with VPS Hosting &#8211; Best Plans Available<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#Zip_the_folder_using_the_FIND_option\" >Zip the folder using the FIND option:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#_How_to_zip_directories_using_the_bash_system\" >&nbsp;How to zip directories using the bash system: &nbsp;&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#Launch_Your_Own_Hosting_Business%E2%80%94Start_Reselling_Like_a_Pro_Today\" >Launch Your Own Hosting Business\u2014Start Reselling Like a Pro Today!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/arzhost.com\/blogs\/how-to-zip-a-directory-in-unix\/#Conclusion\" >Conclusion:<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction_to_Zipping_a_Directory_and_Using_UNIX\"><\/span>Introduction to Zipping a Directory and Using UNIX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Zip<\/strong> is like a container in which you compress the files and contain huge data. When you want to transfer a huge data to another place. Then you compress the files and transfer data. you save the <strong>zip<\/strong> files using the<strong> .zip<\/strong> extension. Today websites have heavy data when you want to download some files then you download them in compressed form.<\/p>\n\n\n\n<p>Learning how to zip a directory in Unix and save these files using th<strong>e .zip extension <\/strong>and compress files using software that is installed in your system. Today almost every operating system has a zip system like UNIX, Mac or Windows, etc.<\/p>\n\n\n\n<p>here at <strong><a href=\"https:\/\/arzhost.com\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/\">ARZ Host<\/a><\/strong>. if you use unix you should know <strong>how to zip a directory in UNIX<\/strong>.<\/p>\n\n\n\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/vj317MqYPj8\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_zip_folder_using_the_zip_command_in_UNIX\"><\/span><strong>How to zip folder using the zip command in UNIX:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can zip the files in UNIX by using the zip command. There are many options to zip files, when you use the zip command as well as you use many other options like \u2018-r\u2019 \u2018f\u2019 \u2018u\u2019 \u2018d\u2019 \u2018m\u2019 \u2018j\u2019 \u2018o\u2019 \u20189\u2019 \u2018q\u2019 \u2018v\u2019 \u2018c\u2019 and there are many others every option has its characteristics. But here you use \u2018-r\u2019 option. If you want to zip folder you write these lines of code:<\/p>\n\n\n\n<p><strong>$ zip \u2013r &lt;output_file&gt;&nbsp; &lt;folder_1&gt;&nbsp; &lt;folder_2&gt;&nbsp; \u2026 &lt;folder_n&gt;<\/strong><\/p>\n\n\n\n<p>If you want to archive a folder named \u2018are host\u2019 in a zip file which is \u2018test.zip\u2019. To achieve this task you use these commands:<\/p>\n\n\n\n<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ zip \u2013r test.zip arzhost <\/strong><\/p>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-1e518341 wp-block-button uag-blocks-common-selector\" style=\"--z-index-desktop:479;;--z-index-tablet:undefined;;--z-index-mobile:undefined;\"><div class=\"uagb-cta__wrap\"><h2 class=\"uagb-cta__title\"><span class=\"ez-toc-section\" id=\"Boost_Your_Sites_Performance_with_VPS_Hosting_%E2%80%93_Best_Plans_Available\"><\/span><a href=\"https:\/\/arzhost.com\/vps\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/vps\/\">Boost Your Site\u2019s Performance with VPS Hosting &#8211; Best Plans Available<\/a><span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"uagb-cta__desc\">Unlock the Potential of VPS Hosting &#8211; Starter Plan starts at just <strong>$12.50\/month<\/strong><\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/arzhost.com\/vps\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_self\" rel=\"noopener noreferrer\">Read More<\/a><\/div><\/div>\n\n\n\n<p>If you want to see whether our zip file is created or not then you use the \u2018Is\u2019 command for the archive file.<\/p>\n\n\n\n<p><strong>&nbsp;<\/strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ Is \u2013 I&nbsp; |&nbsp; grep .zip<\/strong><strong>&nbsp;<\/strong><\/p>\n\n\n\n<p>If you don\u2019t know where your zip file is stored then you use these lines of code to find your files.<\/p>\n\n\n\n<p><strong>&nbsp;<\/strong><strong>$ find&nbsp; \/&nbsp; -name&nbsp; * .zip&nbsp; 2&gt;&nbsp; \/dev\/null<\/strong><strong>&nbsp;<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Zip_the_folder_using_the_FIND_option\"><\/span><strong>Zip the folder using the FIND option:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One of the most powerful commands is to zip files into your folders. you use the<strong> \u2018FIND\u2019 <\/strong>command and link it to the \u2018exec\u2019 option to execute the zip command. If you want to zip your folders in the current working directory then you use these lines of code.<\/p>\n\n\n\n<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ find . -maxdepth 1 -type d -exec zip archive.zip {} +\\<\/strong><strong>&nbsp;<\/strong><strong>&nbsp;&nbsp;&nbsp;&nbsp;<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" title=\"cURL Connection Reset by Peer &#8211; How do we Fix it?\" src=\"https:\/\/arzhost.com\/inc\/uploads\/2020\/11\/zip-folder-using-find.png\" alt=\"zip folder using find\" class=\"wp-image-1771\"\/><\/figure><\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"_How_to_zip_directories_using_the_bash_system\"><\/span><strong>&nbsp;How to zip directories using the bash system: &nbsp;&nbsp;<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>you can zip folders using a bash programming language. Sometimes you do not have any GUI then you can zip files in CLI using bash programming. If you want to zip any folder in bash language then you use <strong>\u2018for loop\u2019. <\/strong>you&nbsp;follow these lines of code:<\/p>\n\n\n\n<p><strong><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ for file in $(ls -d *\/); do zip archive.zip $file; done<\/em><\/strong><strong>&nbsp;<\/strong><strong>&nbsp;<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" title=\"How to Make Sure a File is in a NTFS Volume\" src=\"https:\/\/arzhost.com\/inc\/uploads\/2020\/11\/zip-directories-using-bash.png\" alt=\"zip directories using bash\" class=\"wp-image-1772\"\/><\/figure><\/div>\n\n\n<p><strong>Related Article: <a href=\"https:\/\/arzhost.com\/blogs\/how-to-run-a-bash-script-in-terminal\/\">How to Run a Bash Script in Terminal<\/a><\/strong><\/p>\n\n\n\n<p>If you want to zip a folder that starts with any letter e.g. E . A folder starts with an E letter then you follow these lines of code:<\/p>\n\n\n\n<p><strong><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ for file in $(ls -d *\/ | grep E); do zip archive.zip $file; done<\/em><\/strong><strong><em>&nbsp;<\/em><\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" title=\"Make Sure the File is in a NTFS Volume\" src=\"https:\/\/arzhost.com\/inc\/uploads\/2020\/11\/zip-a-folder.png\" alt=\"zip a folder\" class=\"wp-image-1773\"\/><\/figure><\/div>\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-cf5921a7 wp-block-button uag-blocks-common-selector\" style=\"--z-index-desktop:479;;--z-index-tablet:undefined;;--z-index-mobile:undefined;\"><div class=\"uagb-cta__wrap\"><h2 class=\"uagb-cta__title\"><span class=\"ez-toc-section\" id=\"Launch_Your_Own_Hosting_Business%E2%80%94Start_Reselling_Like_a_Pro_Today\"><\/span><a href=\"https:\/\/arzhost.com\/reseller-hosting\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/reseller-hosting\/\">Launch Your Own Hosting Business\u2014Start Reselling Like a Pro Today!<\/a><span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"uagb-cta__desc\">Start Reselling Hosting with Confidence &#8211; Economy Plan starts at <strong>$12.99\/-<\/strong><\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/arzhost.com\/reseller-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_self\" rel=\"noopener noreferrer\">Read More<\/a><\/div><\/div>\n\n\n\n<p>you have to zip our folder successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion: <\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>by reading this article we hope that you know How to Zip a Directory in Unix.<\/p>\n\n\n\n<p>Subscribe to our <a href=\"https:\/\/arzhost.com\/blogs\/\"><strong>Blog<\/strong><\/a> and get the latest News regarding Hosting or Technology!<\/p>\n\n\n\n<p><strong>Read more:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-403-forbidden-error-wordpress\/\">How To Fix 403 Forbidden Error WordPress<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-get-the-most-out-of-claude-ai\/\">How To Get The Most Out Of Claude Ai<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/bad-gateway-error-502-the-ultimate-guide-to-quick-fixes\/\">Bad Gateway Error (502): The Ultimate Guide to Quick Fixes<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/a-deep-dive-into-todays-best-linux-distros\/\">A Deep Dive Into Today\u2019s Best Linux Distros<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/domain-investor-terms-powerful-strategy\/\">Domain Investor Terms: Expert Insight on Powerful Strategy<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Introduction to Zipping a Directory and Using UNIX Zip is like a container in which you compress the files and contain huge data. When you want to transfer a huge data to another place. Then you compress the files and transfer data. you save the zip files using the .zip extension. Today websites have heavy [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":2999,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"table_tags":[],"class_list":["post-2569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/2569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=2569"}],"version-history":[{"count":2,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/2569\/revisions"}],"predecessor-version":[{"id":3595,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/2569\/revisions\/3595"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/2999"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=2569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=2569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=2569"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=2569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}