{"id":81,"date":"2014-03-18T17:28:59","date_gmt":"2014-03-18T17:28:59","guid":{"rendered":"http:\/\/192.168.1.102\/?p=81"},"modified":"2014-03-18T17:28:59","modified_gmt":"2014-03-18T17:28:59","slug":"command-line-zip-unzip-and-tar","status":"publish","type":"post","link":"https:\/\/digitalsos.net\/?p=81","title":{"rendered":"Command line zip, unzip, and tar"},"content":{"rendered":"<p>In maintaining linux systems I often find that I need to zip the contents of a folder or unzip some settings.\u00a0 Zip is useful for compressing and transmitting files.\u00a0 There isn&#8217;t anything new here and it is straight out of the man pages but since I only use it once every 6 months I&#8217;m going to summarize it here.<\/p>\n<p>To zip a group of files in a directory, cd to that directory and with the command below you get stuff.zip in the same directory:<\/p>\n<pre><code>zip stuff *<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>If you want the hidden files in a directory add the . wildcard:<\/p>\n<pre><code>zip stuff .* *<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>That doesn&#8217;t get you any subdirectories to get that use:<\/p>\n<pre><code>zip -r stuff foo<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>That command will create a stuff.zip archive of the foo directory.<\/p>\n<p>To unzip stuff.zip into the current directory and any subdirectories below it, creating subdirectories as necessary:<\/p>\n<pre><code>unzip stuff<\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre><code>unzip -tq stuff<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>Will test and print out if the Archive is OK.<\/p>\n<p>&nbsp;<\/p>\n<p>Tar files like Newfile.tar.Z can gzip on creation or extraction. To unarchive a tar file use<\/p>\n<pre><code>tar -xvf Newfile.tar<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>or<\/p>\n<pre><code>tar -Zxvf Newfile.tar.Z  #Capitol Z is used for compress or<\/code><\/pre>\n<pre><code>tar -zxvf Newfile.tar.zip  #for a gzip, gunzip file or<\/code><\/pre>\n<pre><code>tar -jxvf Newfile.tar.bzip2  #for a bzip2 archive<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>where -z -Z -j or -a (auto-compress) will compress. -x = extract, -v = verbose, -t = file<\/p>\n<pre><code>tar -cf Newfile.tar foo bar<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>-c = create will create an archive of foo and bar files.\u00a0 You can use * for the directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In maintaining linux systems I often find that I need to zip the contents of a folder or unzip some settings.\u00a0 Zip is useful for compressing and transmitting files.\u00a0 There isn&#8217;t anything new here and it is straight out of the man pages but since I only use it once every 6 months I&#8217;m going<\/p>\n<div class=\"read-more-wrapper\"><a class=\"read-more\" href=\"https:\/\/digitalsos.net\/?p=81\" title=\"Read More\"> <span class=\"button \">Read More<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[19],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-linux"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgxmGV-1j","_links":{"self":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":3,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":84,"href":"https:\/\/digitalsos.net\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/84"}],"wp:attachment":[{"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitalsos.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}