{"id":5611,"date":"2013-05-26T12:04:34","date_gmt":"2013-05-26T16:04:34","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=5611"},"modified":"2013-05-26T12:04:34","modified_gmt":"2013-05-26T16:04:34","slug":"exclude-options-for-tar","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/","title":{"rendered":"Exclude Options for Tar +"},"content":{"rendered":"<p>Quick thought&#8230;<\/p>\n<p>You can pretty much exclude a file, folder or specific pattern when using tar:<\/p>\n<p><code><br \/>\n# tar cvfp 052613tar.tar \/my\/path\/Example.com_DIR --exclude=\/my\/path\/Example.com_DIR\/images<br \/>\n<\/code><br \/>\n&nbsp;<br \/>\nor tar everything in the current directory, but exclude two specific files<br \/>\n<code><br \/>\n# tar cvpf 052613tar.tar * --exclude=index.html --exclude=myimage.png<br \/>\n<\/code><br \/>\n&nbsp;<br \/>\nor<br \/>\n<code><br \/>\ntar cvpf 052613tar.tar * --exclude='file1' --exclude='pattern*' --exclude='file2'<br \/>\n<\/code><br \/>\n&nbsp;&nbsp;<\/p>\n<hr \/>\n<p>p.s some tar basics&#8230;<\/p>\n<p><!--more--><\/p>\n<p><strong>Creating a tar file<\/strong><\/p>\n<p><code>tar -cf tarfile.tar file1.txt<\/code><\/p>\n<p>-c  &#8211; create<br \/>\n-f or \u2013file &#8211; immediately followed by a file or device will tell tar where to create the tar file and the files or directories to package<\/p>\n<p>&nbsp;<br \/>\n <strong>Extracting a tar file<\/strong><br \/>\n<code>tar -xf tarfile.tar<\/code><br \/>\n-x  &#8211; extract<br \/>\n-f or \u2013file<br \/>\n &nbsp;<\/p>\n<p><strong>Add Verbose output<\/strong><br \/>\n<code>tar -xfv tarfile.tar<\/code><br \/>\n-v verbosely lists the files processed<br \/>\n &nbsp;<\/p>\n<p><strong>List files in a tar<\/strong><br \/>\n<code>tar -tf file.tar<\/code><br \/>\n &nbsp;<\/p>\n<p><strong>Add file to tar<\/strong><br \/>\n<code>tar -rvf file.tar file2.txt<br \/>\n file2.txt<\/code><br \/>\n &nbsp;<\/p>\n<p><strong>Add gzip compression<\/strong><br \/>\n<code>tar -cvzf tarfile.tar.gz file1.txt file2.txt<br \/>\nfile1.txt<br \/>\nfile2.txt<\/code><br \/>\n &nbsp;<\/p>\n<p><strong>Add bzip2 compression<\/strong><br \/>\n<code>tar -cjvf tarfile.tar.bz files_dir<br \/>\nfiles_dir\/<br \/>\nfiles_dir\/file3.txt<br \/>\nfiles_dir\/file4.txt<\/code><br \/>\n&nbsp;<\/p>\n<p><strong>Extract tarballs with compression<\/strong><br \/>\n<code>tar -xjvf tarfile.tar.bz files_dir<br \/>\nfiles_dir\/<br \/>\nfiles_dir\/file3.txt<br \/>\nfiles_dir\/file4.txt<\/code><br \/>\n&nbsp;<\/p>\n<p><strong>Extract a tarball without replacing old files<\/strong><br \/>\n<code>tar -czf tarfile.tar.gz file1.txt file2.txt<br \/>\nrm file2.txt && echo \"file2 was removed\" >> file1.txt<br \/>\ntar -xvzkf tarfile.tar.gz<br \/>\nfile1.txt<br \/>\nfile2.txt<br \/>\ncat file1.txt<br \/>\nfile2 was removed <\/code><br \/>\n&nbsp;<\/p>\n<p><strong>Tarpipe\/TarCopy<\/strong><br \/>\nThis sends the packaged files to stdout rather than to a file. This is used as an alternative to &#8216;cp&#8217; because it&#8217;s simply faster.<br \/>\n<code>tar -cf - file* | (cd ..\/files_copied\/ && tar -xf -)<\/code><\/p>\n<p>To copy the files to a remote server<br \/>\n<code>tar -cf - file* | ssh remote-server \"(cd \/files_copied\/ && tar -xf -)\"<\/code><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick thought&#8230; You can pretty much exclude a file, folder or specific pattern when using tar: # tar cvfp 052613tar.tar \/my\/path\/Example.com_DIR &#8211;exclude=\/my\/path\/Example.com_DIR\/images &nbsp; or tar everything in the current directory, but exclude two specific files # tar cvpf 052613tar.tar * &#8211;exclude=index.html &#8211;exclude=myimage.png &nbsp; or tar cvpf 052613tar.tar * &#8211;exclude=&#8217;file1&#8242; &#8211;exclude=&#8217;pattern*&#8217; &#8211;exclude=&#8217;file2&#8242; &nbsp;&nbsp; p.s some tar&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-5611","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exclude Options for Tar + - Linux Shtuff<\/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:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exclude Options for Tar + - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"Quick thought&#8230; You can pretty much exclude a file, folder or specific pattern when using tar: # tar cvfp 052613tar.tar \/my\/path\/Example.com_DIR --exclude=\/my\/path\/Example.com_DIR\/images &nbsp; or tar everything in the current directory, but exclude two specific files # tar cvpf 052613tar.tar * --exclude=index.html --exclude=myimage.png &nbsp; or tar cvpf 052613tar.tar * --exclude=&#039;file1&#039; --exclude=&#039;pattern*&#039; --exclude=&#039;file2&#039; &nbsp;&nbsp; p.s some tar... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-26T16:04:34+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Exclude Options for Tar +\",\"datePublished\":\"2013-05-26T16:04:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/\"},\"wordCount\":166,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/\",\"name\":\"Exclude Options for Tar + - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2013-05-26T16:04:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/exclude-options-for-tar\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exclude Options for Tar +\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exclude Options for Tar + - Linux Shtuff","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:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/","og_locale":"en_US","og_type":"article","og_title":"Exclude Options for Tar + - Linux Shtuff","og_description":"Quick thought&#8230; You can pretty much exclude a file, folder or specific pattern when using tar: # tar cvfp 052613tar.tar \/my\/path\/Example.com_DIR --exclude=\/my\/path\/Example.com_DIR\/images &nbsp; or tar everything in the current directory, but exclude two specific files # tar cvpf 052613tar.tar * --exclude=index.html --exclude=myimage.png &nbsp; or tar cvpf 052613tar.tar * --exclude='file1' --exclude='pattern*' --exclude='file2' &nbsp;&nbsp; p.s some tar... Read More","og_url":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2013-05-26T16:04:34+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Exclude Options for Tar +","datePublished":"2013-05-26T16:04:34+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/"},"wordCount":166,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/","url":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/","name":"Exclude Options for Tar + - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2013-05-26T16:04:34+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/exclude-options-for-tar\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Exclude Options for Tar +"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/5611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=5611"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/5611\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=5611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=5611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=5611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}