{"id":11456,"date":"2019-03-14T08:04:55","date_gmt":"2019-03-14T08:04:55","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11456"},"modified":"2019-03-14T08:04:55","modified_gmt":"2019-03-14T08:04:55","slug":"how-to-split-large-tar-archive-into-multiple-files-of-certain-size","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-split-large-tar-archive-into-multiple-files-of-certain-size\/","title":{"rendered":"How to Split Large \u2018tar\u2019 Archive into Multiple Files of Certain Size"},"content":{"rendered":"<p>Are you worried of transferring or uploading large files over a network, then worry no more, because you can move your files in bits to deal with slow network speeds by splitting them into blocks of a given size.<\/p>\n<p>In this how-to guide, we shall briefly explore the creation of archive files and splitting them into blocks of a selected size. We shall use\u00a0<code>tar<\/code>, one of the most popular archiving utilities on Linux and also take advantage of the\u00a0<code>split<\/code>\u00a0utility to help us break our archive files into small bits.<\/p>\n<div id=\"attachment_21710\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-tar-into-Multiple-Files-Parts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21710\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-tar-into-Multiple-Files-Parts.png\" alt=\"Create and Split tar into Multiple Files or Parts in Linux\" width=\"720\" height=\"345\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create and Split tar into Multiple Files or Parts in Linux<\/p>\n<\/div>\n<p>Before we move further, let us take note of, how these utilities can be used, the general syntax of a\u00a0<code>tar<\/code>\u00a0and\u00a0<code>split<\/code>\u00a0command is as follows:<\/p>\n<pre># tar options archive-name files \r\n# split options file \"prefix\u201d\r\n<\/pre>\n<p>Let us now delve into a few examples to illustrate the main concept of this article.<\/p>\n<p><strong>Example 1<\/strong>: We can first of all create an archive file as follows:<\/p>\n<pre>$ tar -cvjf home.tar.bz2 \/home\/aaronkilik\/Documents\/* \r\n<\/pre>\n<div id=\"attachment_21703\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-Tar-Archive-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21703\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-Tar-Archive-File.png\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-Tar-Archive-File.png 776w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-Tar-Archive-File-768x465.png 768w\" alt=\"Create Tar Archive File\" width=\"776\" height=\"470\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create Tar Archive File<\/p>\n<\/div>\n<p>To confirm that out archive file has been created and also check its size, we can use\u00a0<a href=\"https:\/\/www.tecmint.com\/15-basic-ls-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">ls command<\/a>:<\/p>\n<pre>$ ls -lh home.tar.bz2\r\n<\/pre>\n<p>Then using the split utility, we can break the\u00a0<code>home.tar.bz2<\/code>\u00a0archive file into small blocks each of size\u00a0<code>10MB<\/code>\u00a0as follows:<\/p>\n<pre>$ split -b 10M home.tar.bz2 \"home.tar.bz2.part\"\r\n$ ls -lh home.tar.bz2.parta*\r\n<\/pre>\n<div id=\"attachment_21704\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-File-into-Parts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21704\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-File-into-Parts.png\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-File-into-Parts.png 776w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-File-into-Parts-768x282.png 768w\" alt=\"Split Tar File into Parts in Linux\" width=\"776\" height=\"285\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Split Tar File into Parts in Linux<\/p>\n<\/div>\n<p>As you can see from the output of the commands above, the\u00a0<strong>tar<\/strong>\u00a0archive file has been split to four parts.<\/p>\n<p><strong>Note<\/strong>: In the\u00a0<strong>split<\/strong>\u00a0command above, the option\u00a0<code>-b<\/code>\u00a0is used to specify the size of each block and the\u00a0<code>\"home.tar.bz2.part\"<\/code>\u00a0is the prefix in the name of each block file created after splitting.<\/p>\n<p><strong>Example 2:<\/strong>\u00a0Similar to the case above, here, we can create an archive file of a\u00a0<strong>Linux Mint ISO<\/strong>\u00a0image file.<\/p>\n<pre>$ tar -cvzf linux-mint-18.tar.gz linuxmint-18-cinnamon-64bit.iso \r\n<\/pre>\n<p>Then follow the same steps in\u00a0<strong>example 1<\/strong>\u00a0above to split the archive file into small bits of size\u00a0<code>200MB<\/code>.<\/p>\n<pre>$ ls -lh linux-mint-18.tar.gz \r\n$ split -b 200M linux-mint-18.tar.gz \"ISO-archive.part\"\r\n$ ls -lh ISO-archive.parta*\r\n<\/pre>\n<div id=\"attachment_21705\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-Archive-File-to-Fixed-Sizes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21705\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-Archive-File-to-Fixed-Sizes.png\" sizes=\"auto, (max-width: 777px) 100vw, 777px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-Archive-File-to-Fixed-Sizes.png 777w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Split-Tar-Archive-File-to-Fixed-Sizes-768x377.png 768w\" alt=\"Split Tar Archive File to Fixed Sizes\" width=\"777\" height=\"381\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Split Tar Archive File to Fixed Sizes<\/p>\n<\/div>\n<p><strong>Example 3:<\/strong>\u00a0In this instance, we can use a\u00a0<strong>pipe<\/strong>\u00a0to connect the output of the\u00a0<strong>tar<\/strong>\u00a0command to split as follows:<\/p>\n<pre>$ tar -cvzf - wget\/* | split -b 150M - \"downloads-part\"\r\n<\/pre>\n<div id=\"attachment_21706\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-and-Split-Tar-Archive-File-into-Parts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21706\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-and-Split-Tar-Archive-File-into-Parts.png\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-and-Split-Tar-Archive-File-into-Parts.png 778w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Create-and-Split-Tar-Archive-File-into-Parts-768x468.png 768w\" alt=\"Create and Split Tar Archive File into Parts\" width=\"778\" height=\"474\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create and Split Tar Archive File into Parts<\/p>\n<\/div>\n<p>Confirm the files:<\/p>\n<pre>$ ls -lh downloads-parta*\r\n<\/pre>\n<div id=\"attachment_21707\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Check-Parts-of-Tar-Files.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21707\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Check-Parts-of-Tar-Files.png\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Check-Parts-of-Tar-Files.png 776w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Check-Parts-of-Tar-Files-768x132.png 768w\" alt=\"Check Parts of Tar Files\" width=\"776\" height=\"133\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Parts of Tar Files<\/p>\n<\/div>\n<p>In this last example, we do not have to specify an archive name as you have noticed, simply use a\u00a0<code>-<\/code>\u00a0sign.<\/p>\n<h3>How to Join Tar Files After Splitting<\/h3>\n<p>After successfully splitting tar files or any large file in Linux, you can join the files using the\u00a0<a href=\"https:\/\/www.tecmint.com\/13-basic-cat-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>. Employing\u00a0<strong>cat<\/strong>\u00a0is the most efficient and reliable method of performing a joining operation.<\/p>\n<p>To join back all the blocks or tar files, we issue the command below:<\/p>\n<pre># cat home.tar.bz2.parta* &gt;backup.tar.gz.joined\r\n<\/pre>\n<p>We can see that after running the\u00a0<a href=\"https:\/\/www.tecmint.com\/learn-linux-cat-command-and-tac-command\/\" target=\"_blank\" rel=\"noopener\">cat command<\/a>, it combines all the small blocks we had earlier on created to the original tar archive file of the same size.<\/p>\n<h3>Conclusion<\/h3>\n<p>The whole idea is simple, as we have illustrated above, you simply need to know and understand how to use the various options of\u00a0<code>tar<\/code>\u00a0and\u00a0<code>split<\/code>\u00a0utilities.<\/p>\n<p>You can refer to their manual entry pages of to learn more other options and perform some complex operations or you can go through the following article to learn more about\u00a0<strong>tar<\/strong>\u00a0command.<\/p>\n<p><b>Don\u2019t Miss:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/18-tar-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">18 Useful \u2018tar\u2019 Command Examples<\/a><\/p>\n<p>For any questions or further tips, you can share your thoughts via the comment section below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/split-large-tar-into-multiple-files-of-certain-size\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you worried of transferring or uploading large files over a network, then worry no more, because you can move your files in bits to deal with slow network speeds by splitting them into blocks of a given size. In this how-to guide, we shall briefly explore the creation of archive files and splitting them &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/14\/how-to-split-large-tar-archive-into-multiple-files-of-certain-size\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Split Large \u2018tar\u2019 Archive into Multiple Files of Certain Size&#8221;<\/span><\/a><\/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":[],"class_list":["post-11456","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11456"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11456\/revisions"}],"predecessor-version":[{"id":11457,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11456\/revisions\/11457"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}