{"id":378,"date":"2023-04-24T16:34:23","date_gmt":"2023-04-24T16:34:23","guid":{"rendered":"https:\/\/santosh-shah.com\/blog\/?p=378"},"modified":"2023-09-29T11:18:54","modified_gmt":"2023-09-29T11:18:54","slug":"zip-and-unzip-with-command-using-terminal","status":"publish","type":"post","link":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/","title":{"rendered":"Zip and unzip with command using terminal"},"content":{"rendered":"\n<p>There are various package that does this job but we will talk about `tar` that simply zip and uzip files and folders. This small article will show you how to zip and unzip with command using terminal.<\/p>\n\n\n\n<p>To zip files<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -czvf zip_file_name.tar.gz -C .\/dist .<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>f<\/code>: this must be the last flag of the command, and the tar\u00a0file must be immediately after. It tells tar the name and path of the compressed file.<\/li>\n\n\n\n<li><code>z<\/code>: tells tar to decompress the archive using g<strong>z<\/strong>ip<\/li>\n\n\n\n<li><code>x<\/code>: tar can collect files or e<strong>x<\/strong>tract them.&nbsp;<code>x<\/code>&nbsp;does the latter.<\/li>\n\n\n\n<li><code>v<\/code>: makes tar talk a lot.\u00a0<strong>V<\/strong>erbose output shows you all the files being extracted.<\/li>\n<\/ul>\n\n\n\n<p>To unzip files<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xvzf uploadable.tar.gz -C .\/.<\/code><\/pre>\n\n\n\n<p>To extract into a custom folder, add the -C option with a folder name of your choice. As above code it represent current directory with all file denote as dot ( . )<\/p>\n\n\n\n<p>At some point\u00a0<code>tar<\/code>\u00a0was upgraded to auto-decompress. So you can also remove v and z.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xf uploadable.tar.gz<\/code><\/pre>\n\n\n\n<p>Note the lack of hyphen for the command flags. This is because most versions of tar allow both gnu and bsd style options (simplistically, gnu requires a hyphen, bsd doesn&#8217;t).<\/p>\n\n\n\n<p><a href=\"https:\/\/askubuntu.com\/questions\/25347\/what-command-do-i-need-to-unzip-extract-a-tar-gz-file\">credit link<\/a> unzip file<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/939982\/how-do-i-tar-a-directory-of-files-and-folders-without-including-the-directory-it\">Credit link 2<\/a>  Zip file and folder<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are various package that does this job but we will talk about `tar` that simply zip and uzip files and folders. This small article will show you how to zip and unzip with command using terminal. To zip files To unzip files To extract into a custom folder, add the -C option with a [&hellip;]<\/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":[15,31],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux","tag-mac-command-to-zip-and-unzip"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Zip and unzip with command using terminal - Santosh Kumar Shah<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Zip and unzip with command using terminal - Santosh Kumar Shah\" \/>\n<meta property=\"og:description\" content=\"There are various package that does this job but we will talk about `tar` that simply zip and uzip files and folders. This small article will show you how to zip and unzip with command using terminal. To zip files To unzip files To extract into a custom folder, add the -C option with a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/\" \/>\n<meta property=\"og:site_name\" content=\"Santosh Kumar Shah\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-24T16:34:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-29T11:18:54+00:00\" \/>\n<meta name=\"author\" content=\"Santosh Kumar Shah\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Santosh Kumar Shah\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/\",\"url\":\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/\",\"name\":\"Zip and unzip with command using terminal - Santosh Kumar Shah\",\"isPartOf\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\"},\"datePublished\":\"2023-04-24T16:34:23+00:00\",\"dateModified\":\"2023-09-29T11:18:54+00:00\",\"author\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\"},\"breadcrumb\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/santosh-shah.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Zip and unzip with command using terminal\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\",\"url\":\"https:\/\/santosh-shah.com\/blog\/\",\"name\":\"Santosh Kumar Shah\",\"description\":\"JavaScript Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\",\"name\":\"Santosh Kumar Shah\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"caption\":\"Santosh Kumar Shah\"},\"description\":\"I am JavaScript developer.\",\"sameAs\":[\"https:\/\/santosh-shah.com\/blog\"],\"url\":\"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Zip and unzip with command using terminal - Santosh Kumar Shah","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/","og_locale":"en_US","og_type":"article","og_title":"Zip and unzip with command using terminal - Santosh Kumar Shah","og_description":"There are various package that does this job but we will talk about `tar` that simply zip and uzip files and folders. This small article will show you how to zip and unzip with command using terminal. To zip files To unzip files To extract into a custom folder, add the -C option with a [&hellip;]","og_url":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/","og_site_name":"Santosh Kumar Shah","article_published_time":"2023-04-24T16:34:23+00:00","article_modified_time":"2023-09-29T11:18:54+00:00","author":"Santosh Kumar Shah","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Santosh Kumar Shah","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/","url":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/","name":"Zip and unzip with command using terminal - Santosh Kumar Shah","isPartOf":{"@id":"https:\/\/santosh-shah.com\/blog\/#website"},"datePublished":"2023-04-24T16:34:23+00:00","dateModified":"2023-09-29T11:18:54+00:00","author":{"@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f"},"breadcrumb":{"@id":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/santosh-shah.com\/blog\/zip-and-unzip-with-command-using-terminal\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/santosh-shah.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Zip and unzip with command using terminal"}]},{"@type":"WebSite","@id":"https:\/\/santosh-shah.com\/blog\/#website","url":"https:\/\/santosh-shah.com\/blog\/","name":"Santosh Kumar Shah","description":"JavaScript Developer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f","name":"Santosh Kumar Shah","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","caption":"Santosh Kumar Shah"},"description":"I am JavaScript developer.","sameAs":["https:\/\/santosh-shah.com\/blog"],"url":"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/"}]}},"_links":{"self":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/comments?post=378"}],"version-history":[{"count":1,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/378\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/378\/revisions\/379"}],"wp:attachment":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/media?parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/categories?post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/tags?post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}