{"id":804,"date":"2015-11-08T23:24:14","date_gmt":"2015-11-08T22:24:14","guid":{"rendered":"https:\/\/blog.christiaan008.com\/?p=804"},"modified":"2021-09-02T11:27:19","modified_gmt":"2021-09-02T10:27:19","slug":"dynamically-splitting-output-into-files-while-processing","status":"publish","type":"post","link":"https:\/\/blog.christiaan008.com\/?p=804","title":{"rendered":"Dynamically splitting output into files while processing"},"content":{"rendered":"\n[et_pb_section admin_label=&#8221;Section&#8221; fullwidth=&#8221;on&#8221; specialty=&#8221;off&#8221; background_image=&#8221;https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_code.jpg&#8221; transparent_background=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; inner_shadow=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; padding_mobile=&#8221;off&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;off&#8221; width_unit=&#8221;on&#8221; make_equal=&#8221;off&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243;][et_pb_fullwidth_header admin_label=&#8221;Fullwidth Header&#8221; title=&#8221;Dynamically splitting output into files while processing&#8221; background_layout=&#8221;dark&#8221; text_orientation=&#8221;center&#8221; header_fullscreen=&#8221;on&#8221; header_scroll_down=&#8221;off&#8221; background_url=&#8221;https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg&#8221; background_overlay_color=&#8221;rgba(0,0,0,0.2)&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; content_orientation=&#8221;center&#8221; image_orientation=&#8221;center&#8221; title_font_size=&#8221;35px&#8221; custom_button_one=&#8221;off&#8221; button_one_text_size=&#8221;20&#8243; button_one_border_width=&#8221;2&#8243; button_one_border_radius=&#8221;3&#8243; button_one_letter_spacing=&#8221;0&#8243; button_one_use_icon=&#8221;default&#8221; button_one_icon_placement=&#8221;right&#8221; button_one_on_hover=&#8221;on&#8221; button_one_border_radius_hover=&#8221;3&#8243; button_one_letter_spacing_hover=&#8221;0&#8243; custom_button_two=&#8221;off&#8221; button_two_text_size=&#8221;20&#8243; button_two_border_width=&#8221;2&#8243; button_two_border_radius=&#8221;3&#8243; button_two_letter_spacing=&#8221;0&#8243; button_two_use_icon=&#8221;default&#8221; button_two_icon_placement=&#8221;right&#8221; button_two_on_hover=&#8221;on&#8221; button_two_border_radius_hover=&#8221;3&#8243; button_two_letter_spacing_hover=&#8221;0&#8243;] [\/et_pb_fullwidth_header][\/et_pb_section][et_pb_section admin_label=&#8221;section&#8221;][et_pb_row admin_label=&#8221;row&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;on&#8221; width_unit=&#8221;off&#8221; custom_width_percent=&#8221;50%&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243; padding_mobile=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; make_equal=&#8221;off&#8221; parallax_1=&#8221;off&#8221; parallax_method_1=&#8221;off&#8221; column_padding_mobile=&#8221;on&#8221;][et_pb_column type=&#8221;4_4&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; text_font_size=&#8221;16&#8243; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221; text_letter_spacing=&#8221;1px&#8221;]\r\n\r\nSometimes I just want to write a script because it can be useful or because I&#8217;m curious to figure out how to solve a problem. Most of the times when I&#8217;m scripting one of the above is the motive to start and create a script for something and sometimes the purposes is completely unclear at first sight.\r\n\r\nSitting at a department store doing a bit of work, I was adjusting a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Shell_script\" target=\"_blank\" rel=\"noopener\">Shell<\/a>\u00a0script that I&#8217;ve wrote. The shell\u00a0script was generating a lot of output that serves as input for another process. Since the script needs to process thousands of entries I needed to wait for the script to finish.\r\n\r\nInstead of waiting a couple of hours for the processing to be done I was looking\u00a0for a way to automatically split the output of a shell\u00a0script into a file after a certain amount of entries processed. In other words dynamically create different text files with the output generated by the script depending on the amount of processed entries.\r\n\r\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row admin_label=&#8221;Row&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;on&#8221; width_unit=&#8221;off&#8221; custom_width_percent=&#8221;50%&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243; padding_mobile=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; make_equal=&#8221;off&#8221; parallax_1=&#8221;off&#8221; parallax_method_1=&#8221;off&#8221; parallax_2=&#8221;off&#8221; parallax_method_2=&#8221;off&#8221; column_padding_mobile=&#8221;on&#8221; custom_padding=&#8221;5%|||&#8221;][et_pb_column type=&#8221;1_2&#8243;][et_pb_image admin_label=&#8221;Image&#8221; src=&#8221;https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/numbers_script.jpg&#8221; alt=&#8221;Numbers script&#8221; show_in_lightbox=&#8221;on&#8221; url_new_window=&#8221;off&#8221; animation=&#8221;off&#8221; sticky=&#8221;off&#8221; align=&#8221;left&#8221; force_fullwidth=&#8221;off&#8221; always_center_on_mobile=&#8221;on&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221; title_text=&#8221;Numbers script&#8221;] [\/et_pb_image][\/et_pb_column][et_pb_column type=&#8221;1_2&#8243;][et_pb_divider admin_label=&#8221;Divider&#8221; color=&#8221;#ffffff&#8221; show_divider=&#8221;off&#8221; height=&#8221;20&#8243; divider_style=&#8221;solid&#8221; divider_position=&#8221;top&#8221; divider_weight=&#8221;1&#8243; hide_on_mobile=&#8221;on&#8221;] [\/et_pb_divider][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; text_font_size=&#8221;16&#8243; text_letter_spacing=&#8221;1px&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]\r\n\r\nThe example script on the <a href=\"https:\/\/wiki.christiaan008.com\/index.php\/Dynamically_splitting_output_into_files_while_processing\" target=\"_blank\" rel=\"noopener\">Wiki<\/a>\u00a0is a simplified version of a 30 minute scripting session, during which one of the employees of the department store asked if the food had tasted good and she could take away my serving tray.\r\n\r\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row admin_label=&#8221;Row&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;on&#8221; width_unit=&#8221;off&#8221; custom_width_percent=&#8221;50%&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243; padding_mobile=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; make_equal=&#8221;off&#8221; parallax_1=&#8221;off&#8221; parallax_method_1=&#8221;off&#8221; parallax_2=&#8221;off&#8221; parallax_method_2=&#8221;off&#8221; column_padding_mobile=&#8221;on&#8221; custom_padding=&#8221;5%|||&#8221;][et_pb_column type=&#8221;2_3&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; text_font_size=&#8221;16&#8243; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221; text_letter_spacing=&#8221;1px&#8221;]\r\n\r\nThe function of the example script is &#8216;very simple&#8217;, during the while loop the script counts till 10 and checks while processing an entry (in this case a number) if the amount of lines in the output file has been reached using the &#8216;wc -l&#8217; command. Off course this can be changed to something else, like a certain value or word using the &#8216;grep&#8217; command. For example if you want to generate a XML file and you want to check how many entries the generated XML file has you can use: &#8216;\u00a0grep -oc &#8220;Your XML entry open or close pattern&#8221; &#8216;\u00a0.\r\n\r\n[\/et_pb_text][\/et_pb_column][et_pb_column type=&#8221;1_3&#8243;][et_pb_image admin_label=&#8221;Image&#8221; src=&#8221;https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/file_content_numbers.jpg&#8221; show_in_lightbox=&#8221;off&#8221; url_new_window=&#8221;off&#8221; animation=&#8221;off&#8221; sticky=&#8221;off&#8221; align=&#8221;left&#8221; force_fullwidth=&#8221;off&#8221; always_center_on_mobile=&#8221;on&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221; alt=&#8221;Content of file&#8221; title_text=&#8221;Content of file&#8221;] [\/et_pb_image][\/et_pb_column][\/et_pb_row][et_pb_row admin_label=&#8221;Row&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;on&#8221; width_unit=&#8221;off&#8221; custom_width_percent=&#8221;50%&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243; padding_mobile=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; make_equal=&#8221;off&#8221; parallax_1=&#8221;off&#8221; parallax_method_1=&#8221;off&#8221; parallax_2=&#8221;off&#8221; parallax_method_2=&#8221;off&#8221; column_padding_mobile=&#8221;on&#8221; custom_padding=&#8221;5%|||&#8221;][et_pb_column type=&#8221;1_3&#8243;][et_pb_image admin_label=&#8221;Image&#8221; src=&#8221;https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/numbers_in_filename.jpg&#8221; alt=&#8221;numbers in filename&#8221; show_in_lightbox=&#8221;off&#8221; url_new_window=&#8221;off&#8221; animation=&#8221;off&#8221; sticky=&#8221;off&#8221; align=&#8221;left&#8221; force_fullwidth=&#8221;off&#8221; always_center_on_mobile=&#8221;on&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221; title_text=&#8221;numbers in filename&#8221;] [\/et_pb_image][\/et_pb_column][et_pb_column type=&#8221;2_3&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; text_font_size=&#8221;16&#8243; text_letter_spacing=&#8221;1px&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]\r\n\r\nIf the value of the counted lines is less then the amount that is set to split a file the current entry is added to the current file, else a new file is generated. The output filename in this script is dynamically generated using a begin and end number.\r\n\r\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row admin_label=&#8221;Row&#8221; make_fullwidth=&#8221;off&#8221; use_custom_width=&#8221;on&#8221; width_unit=&#8221;off&#8221; custom_width_px=&#8221;1550px&#8221; custom_width_percent=&#8221;50%&#8221; use_custom_gutter=&#8221;off&#8221; gutter_width=&#8221;3&#8243; padding_mobile=&#8221;off&#8221; allow_player_pause=&#8221;off&#8221; parallax=&#8221;off&#8221; parallax_method=&#8221;off&#8221; make_equal=&#8221;off&#8221; parallax_1=&#8221;off&#8221; parallax_method_1=&#8221;off&#8221; column_padding_mobile=&#8221;on&#8221; custom_padding=&#8221;5%|||&#8221;][et_pb_column type=&#8221;4_4&#8243;][et_pb_text admin_label=&#8221;Text&#8221; background_layout=&#8221;light&#8221; text_orientation=&#8221;left&#8221; text_font_size=&#8221;16&#8243; text_letter_spacing=&#8221;1px&#8221; use_border_color=&#8221;off&#8221; border_color=&#8221;#ffffff&#8221; border_style=&#8221;solid&#8221;]\r\n\r\nIf you think you can generate the same output easier, faster etc. be my guest!\r\n\r\nCheers,\r\n\r\nChristiaan\r\n\r\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"<p>Sometimes I just want to write a script because it can be useful or because I&#8217;m curious to figure out how to solve a problem. Most of the times when [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":849,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"categories":[43],"tags":[],"class_list":["post-804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Dynamically splitting output into files while processing | Christiaan&#039;s blog<\/title>\n<meta name=\"description\" content=\"Just a simplified example on how to split output from a shell script to dynamically created files.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.christiaan008.com\/?p=804\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dynamically splitting output into files while processing | Christiaan&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"Just a simplified example on how to split output from a shell script to dynamically created files.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.christiaan008.com\/?p=804\" \/>\n<meta property=\"og:site_name\" content=\"Christiaan&#039;s blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/christiaan008\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-08T22:24:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-02T10:27:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christiaan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@christiaan008\" \/>\n<meta name=\"twitter:site\" content=\"@christiaan008\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christiaan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804\"},\"author\":{\"name\":\"Christiaan\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/#\\\/schema\\\/person\\\/80afd7344699708649053651d6583631\"},\"headline\":\"Dynamically splitting output into files while processing\",\"datePublished\":\"2015-11-08T22:24:14+00:00\",\"dateModified\":\"2021-09-02T10:27:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804\"},\"wordCount\":1324,\"image\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.christiaan008.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2015\\\/11\\\/shell_script1_high.jpg\",\"articleSection\":[\"Scripting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804\",\"url\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804\",\"name\":\"Dynamically splitting output into files while processing | Christiaan&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.christiaan008.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2015\\\/11\\\/shell_script1_high.jpg\",\"datePublished\":\"2015-11-08T22:24:14+00:00\",\"dateModified\":\"2021-09-02T10:27:19+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/#\\\/schema\\\/person\\\/80afd7344699708649053651d6583631\"},\"description\":\"Just a simplified example on how to split output from a shell script to dynamically created files.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#primaryimage\",\"url\":\"https:\\\/\\\/blog.christiaan008.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2015\\\/11\\\/shell_script1_high.jpg\",\"contentUrl\":\"https:\\\/\\\/blog.christiaan008.com\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2015\\\/11\\\/shell_script1_high.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/?p=804#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.christiaan008.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Dynamically splitting output into files while processing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/#website\",\"url\":\"https:\\\/\\\/blog.christiaan008.com\\\/\",\"name\":\"Christiaan&#039;s blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.christiaan008.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.christiaan008.com\\\/#\\\/schema\\\/person\\\/80afd7344699708649053651d6583631\",\"name\":\"Christiaan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g\",\"caption\":\"Christiaan\"},\"url\":\"https:\\\/\\\/blog.christiaan008.com\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Dynamically splitting output into files while processing | Christiaan&#039;s blog","description":"Just a simplified example on how to split output from a shell script to dynamically created files.","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:\/\/blog.christiaan008.com\/?p=804","og_locale":"en_US","og_type":"article","og_title":"Dynamically splitting output into files while processing | Christiaan&#039;s blog","og_description":"Just a simplified example on how to split output from a shell script to dynamically created files.","og_url":"https:\/\/blog.christiaan008.com\/?p=804","og_site_name":"Christiaan&#039;s blog","article_publisher":"https:\/\/www.facebook.com\/christiaan008","article_published_time":"2015-11-08T22:24:14+00:00","article_modified_time":"2021-09-02T10:27:19+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg","type":"image\/jpeg"}],"author":"Christiaan","twitter_card":"summary_large_image","twitter_creator":"@christiaan008","twitter_site":"@christiaan008","twitter_misc":{"Written by":"Christiaan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.christiaan008.com\/?p=804#article","isPartOf":{"@id":"https:\/\/blog.christiaan008.com\/?p=804"},"author":{"name":"Christiaan","@id":"https:\/\/blog.christiaan008.com\/#\/schema\/person\/80afd7344699708649053651d6583631"},"headline":"Dynamically splitting output into files while processing","datePublished":"2015-11-08T22:24:14+00:00","dateModified":"2021-09-02T10:27:19+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.christiaan008.com\/?p=804"},"wordCount":1324,"image":{"@id":"https:\/\/blog.christiaan008.com\/?p=804#primaryimage"},"thumbnailUrl":"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg","articleSection":["Scripting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blog.christiaan008.com\/?p=804","url":"https:\/\/blog.christiaan008.com\/?p=804","name":"Dynamically splitting output into files while processing | Christiaan&#039;s blog","isPartOf":{"@id":"https:\/\/blog.christiaan008.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.christiaan008.com\/?p=804#primaryimage"},"image":{"@id":"https:\/\/blog.christiaan008.com\/?p=804#primaryimage"},"thumbnailUrl":"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg","datePublished":"2015-11-08T22:24:14+00:00","dateModified":"2021-09-02T10:27:19+00:00","author":{"@id":"https:\/\/blog.christiaan008.com\/#\/schema\/person\/80afd7344699708649053651d6583631"},"description":"Just a simplified example on how to split output from a shell script to dynamically created files.","breadcrumb":{"@id":"https:\/\/blog.christiaan008.com\/?p=804#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.christiaan008.com\/?p=804"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.christiaan008.com\/?p=804#primaryimage","url":"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg","contentUrl":"https:\/\/blog.christiaan008.com\/wp-content\/uploads\/sites\/2\/2015\/11\/shell_script1_high.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/blog.christiaan008.com\/?p=804#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.christiaan008.com\/"},{"@type":"ListItem","position":2,"name":"Dynamically splitting output into files while processing"}]},{"@type":"WebSite","@id":"https:\/\/blog.christiaan008.com\/#website","url":"https:\/\/blog.christiaan008.com\/","name":"Christiaan&#039;s blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.christiaan008.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.christiaan008.com\/#\/schema\/person\/80afd7344699708649053651d6583631","name":"Christiaan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9dccd3d7797978fc75633bf236d50d191dc2475023f14a9226da5a9a9495288d?s=96&d=mm&r=g","caption":"Christiaan"},"url":"https:\/\/blog.christiaan008.com\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/posts\/804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=804"}],"version-history":[{"count":40,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/posts\/804\/revisions"}],"predecessor-version":[{"id":3606,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/posts\/804\/revisions\/3606"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=\/wp\/v2\/media\/849"}],"wp:attachment":[{"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.christiaan008.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}