{"id":14115,"date":"2023-07-25T07:27:34","date_gmt":"2023-07-25T07:27:34","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=14115"},"modified":"2024-02-12T07:53:57","modified_gmt":"2024-02-12T07:53:57","slug":"bash-run-commands-in-parallel","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/","title":{"rendered":"How to Run Bash Commands in Parallel [4 Ways With Examples]"},"content":{"rendered":"<p style=\"text-align: justify;\">Running <strong>Bash commands<\/strong> in parallel is a technique or method of executing multiple commands simultaneously in a <strong>Bash shell environment<\/strong>. This method helps in reducing overall execution time. In this article, I will discuss different ways to run multiple Bash commands in parallel. I will also show some practical examples with Bash scripts of parallel operations. So let\u2019s start!<\/p>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/Practice-files-of-bash_run_commands_in_parallel.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#e8f9ff;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1aa1d6\"><\/i> Practice Files to Run Bash Commands in Parallel<\/span><\/a><\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#4_Ways_to_Run_Bash_Commands_in_Parallel\" >4 Ways to Run Bash Commands in Parallel<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#1_Ampersand_%E2%80%9C_%E2%80%9D_Sign\" >1. Ampersand &#8220;&amp;&#8221; Sign<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#2_The_%E2%80%9Cwait%E2%80%9D_Command_With_the_Ampersand_%E2%80%9C_%E2%80%9D_Sign\" >2. The &#8220;wait&#8221; Command With the Ampersand &#8220;&amp;&#8221; Sign<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#3_The_%E2%80%9Cxargs%E2%80%9D_Command\" >3. The &#8220;xargs&#8221; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#4_GNU_Parallel\" >4. GNU Parallel<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#3_Practical_Examples_of_Running_Bash_Commands_in_Parallel\" >3 Practical Examples of Running Bash Commands in Parallel<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Example_1_Using_%E2%80%9C_%E2%80%9D_Sign_With_%E2%80%9Cwait%E2%80%9D_Command\" >Example 1: Using &#8220;&amp;&#8221; Sign With &#8220;wait&#8221; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Example_2_Run_Commands_in_Parallel_Using_GNU_Parallel_Command_Tool\" >Example 2: Run Commands in Parallel Using GNU Parallel Command Tool<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Example_3_Run_Commands_in_Parallel_Using_the_%E2%80%9Cxargs%E2%80%9D_Command\" >Example 3: Run Commands in Parallel Using the &#8220;xargs&#8221; Command<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Importance_of_Running_Bash_Commands_in_Parallel\" >Importance of Running Bash Commands in Parallel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#People_Also_Ask\" >People Also Ask<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#Does_bash_run_in_parallel\" >Does bash run in parallel?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#How_do_I_run_two_shell_commands_in_parallel\" >How do I run two shell commands in parallel?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#How_to_do_parallel_execution_in_bash_script\" >How to do parallel execution in bash script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#How_do_I_run_a_bash_command_on_multiple_lines\" >How do I run a bash command on multiple lines?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"4_Ways_to_Run_Bash_Commands_in_Parallel\"><\/span>4 Ways to Run Bash Commands in Parallel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Read out the following described ways, through which you can run multiple <strong>Bash commands <\/strong>of a Bash script in <strong>parallel<\/strong> while executing the script.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Ampersand_%E2%80%9C_%E2%80%9D_Sign\"><\/span>1. Ampersand &#8220;&amp;&#8221; Sign<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">As a simple approach, use the inherent <strong>Bash ampersand (&amp;)<\/strong> operator to run commands in parallel. It allows the execution of a command asynchronously, enabling the shell to proceed to the next command without waiting for the current one to finish.<\/p>\n<p><strong>Basic Syntax:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">command1&amp;\ncommand2&amp;<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_The_%E2%80%9Cwait%E2%80%9D_Command_With_the_Ampersand_%E2%80%9C_%E2%80%9D_Sign\"><\/span>2. The &#8220;wait&#8221; Command With the Ampersand &#8220;&amp;&#8221; Sign<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <strong>wait command<\/strong> waits for all child processes to exit. So using the wait command with the \u2018&amp;\u2019 operator we can run batches of operations. However, the one drawback of using the <strong>wait <\/strong>command is that you can\u2019t get a new process to start as soon as a running process ends.<\/p>\n<p><strong>Basic Syntax:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">command1&amp;\ncommand2&amp;\nwait<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_The_%E2%80%9Cxargs%E2%80%9D_Command\"><\/span>3. The &#8220;xargs&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <a href=\"https:\/\/linuxsimply.com\/xargs-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>xargs command<\/strong><\/a> can be used to execute commands in parallel by combining it with the <code class=\"\" data-line=\"\">-p<\/code> option. This option specifies the maximum number of parallel processes to run.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_GNU_Parallel\"><\/span>4. GNU Parallel<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>GNU Parallel<\/strong> is a powerful tool that allows you to run commands in parallel, providing flexibility and control over the execution process. You can install <strong>GNU Parallel <\/strong>on your system directly from the command line. By default, the parallel is not included &amp; needs to be installed.<\/p>\n<p><strong>Basic Syntax:<\/strong><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">parallel ::: prog1 prog2<\/code><\/pre>\n<p>Here, <code class=\"\" data-line=\"\">:::<\/code> is a <strong>special syntax<\/strong> that tells the command to iterate over a list of<strong> arguments<\/strong>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"3_Practical_Examples_of_Running_Bash_Commands_in_Parallel\"><\/span>3 Practical Examples of Running Bash Commands in Parallel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In the following article, I will explain three practical examples of running <strong>Bash <\/strong>commands in parallel, based on the above-mentioned ways.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_1_Using_%E2%80%9C_%E2%80%9D_Sign_With_%E2%80%9Cwait%E2%80%9D_Command\"><\/span>Example 1: Using &#8220;&amp;&#8221; Sign With &#8220;wait&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In the first example, I will run a <strong>Bash<\/strong> script with multiple commands. Inside the script, I will use the \u201c&amp;\u201d sign along with the <strong>wait<\/strong> command to perform parallel operations among those written <strong>Bash<\/strong> script commands.<\/p>\n<p style=\"text-align: justify;\">To run commands in parallel using the ampersand <code class=\"\" data-line=\"\">&amp;<\/code> with the <code class=\"\" data-line=\"\">wait<\/code> command, see the following Bash script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\n#Command 1 running in the background\nuname&amp;\n#Command 2 running in the background\ndate&amp;\n#Command 3 running in the background\nls -l&amp;\n\n#wait for all background processes to complete\nwait\n\necho &quot;All commands completed&quot;<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"> In\u00a0 the first script line (<strong>#! \/bin\/bash), <\/strong><code class=\"\" data-line=\"\">#!<\/code> is called <strong>shebang<\/strong> or <strong>hashbang<\/strong>. It indicates the interpreter to be used for executing the script, in this case, it\u2019s <strong>Bash<\/strong>. Next, <strong>3 <\/strong>commands are in <strong>3<\/strong> lines along with the <strong>ampersand<\/strong> sign to be executed in parallel.<\/p>\n<p style=\"text-align: justify;\">Afterward, the <strong>wait <\/strong>command waits for all the background processes to complete. When the processes are complete the <a href=\"https:\/\/linuxsimply.com\/echo-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>echo command<\/strong><\/a> prints the completion message. <\/div><\/div><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-14124\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Run-Commands-in-parallel-with-.png\" alt=\"Run bash commands in parallel with '&amp;' operator\" width=\"700\" height=\"503\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Run-Commands-in-parallel-with-.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Run-Commands-in-parallel-with--300x216.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Run-Commands-in-parallel-with--767x551.png 767w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/>After executing, you can see the script has executed all the commands parallelly &amp; displaying the outputs one by one.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_2_Run_Commands_in_Parallel_Using_GNU_Parallel_Command_Tool\"><\/span>Example 2: Run Commands in Parallel Using GNU Parallel Command Tool<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Here, I will use the powerful <strong>GNU <\/strong>command tool <strong>parallel<\/strong>\u00a0to run several<strong> Bash commands <\/strong>within a script in parallel. Now, this command tool is not installed by default. However, you can install it on your <strong>Ubuntu <\/strong>by running the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">sudo apt install parallel<\/code><\/pre>\n<p style=\"text-align: justify;\">To run commands in parallel using the GNU command <code class=\"\" data-line=\"\">parallel<\/code>, check out the following Bash script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\ncommands=(\n\u00a0\u00a0\u00a0\u00a0\u00a0 &quot;date&quot;\n\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0&quot;uname&quot;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &quot;uptime&quot;\n)\nparallel --jobs 3 ::: &quot;${commands[@]}&quot;\n\necho &quot;All commands completed&quot;<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">The script starts with an array called <code class=\"\" data-line=\"\">commands\u00a0<\/code>that holds the commands to be executed in parallel.<\/p>\n<p style=\"text-align: justify;\">After that, the <strong>parallel<\/strong>\u00a0command with the option <code class=\"\" data-line=\"\">--jobs 3<\/code> specifies that a maximum of <strong>3 jobs<\/strong> should be executed concurrently. The <code class=\"\" data-line=\"\">:::<\/code> syntax followed by <code class=\"\" data-line=\"\">&quot;${commands[@]}&quot;<\/code> passes the elements of the<strong> \u2018commands\u2019<\/strong> array as arguments to <strong>\u2018parallel\u2019<\/strong>.<\/div><\/div> <img decoding=\"async\" class=\"aligncenter size-full wp-image-14125\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-Commands-in-parallel-with-GNU-parallel.png\" alt=\"Run bash commands in parallel with GNU parallel tool\" width=\"825\" height=\"218\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-Commands-in-parallel-with-GNU-parallel.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-Commands-in-parallel-with-GNU-parallel-300x79.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Run-Commands-in-parallel-with-GNU-parallel-764x202.png 764w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>The script prints all three commands&#8217; output upon execution along with the <strong>All commands completed <\/strong>message after all the operations are done.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_3_Run_Commands_in_Parallel_Using_the_%E2%80%9Cxargs%E2%80%9D_Command\"><\/span>Example 3: Run Commands in Parallel Using the &#8220;xargs&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In this example, I will use the <strong>xargs<\/strong> command in a <strong>Bash<\/strong> script to run some commands in parallel. To run commands in parallel using the <code class=\"\" data-line=\"\">xargs<\/code> command, please go through the below script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#! \/bin\/bash\n\ncommands=(\n\u00a0\u00a0\u00a0 &quot;ls -l&quot;\n\u00a0\u00a0\u00a0 &quot;date&quot;\n\u00a0\u00a0\u00a0 &quot;whoami&quot;\n)\n\nprintf &quot;%s\\n&quot;\u00a0 &quot;${commands[@]}&quot; | xargs -I {} -P 3 sh -c &quot;{}&quot;\necho &quot;All commands completed&quot;<\/code><\/pre>\n<p style=\"text-align: justify;\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#e1e3e6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\">EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\"> The three commands <strong><a href=\"https:\/\/linuxsimply.com\/ls-command-in-linux\/#Example_4_Listing_in_Long_Format_Using_the_ls_Command\" target=\"_blank\" rel=\"noopener\">ls -l<\/a>, <a href=\"https:\/\/linuxsimply.com\/ncal-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">ncal<\/a>, <\/strong>and <a href=\"https:\/\/linuxsimply.com\/whoami-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>whoami<\/strong><\/a>\u00a0in the script list files &amp; directories, prints date, &amp; display username respectively. Now when you run the script these commands will be executed in parallel using the <strong>xargs <\/strong>command with the <code class=\"\" data-line=\"\">-P<\/code> option where <strong>3<\/strong>\u00a0specifies that a maximum of <strong>3 parallel<\/strong> processes should be running at any given time. The <code class=\"\" data-line=\"\">-I {}<\/code> option replaces occurrences of <code class=\"\" data-line=\"\">{}<\/code>\u00a0in the command with the input.<\/p>\n<p style=\"text-align: justify;\">The <code class=\"\" data-line=\"\">printf &quot;%s\\n&quot;\u00a0 &quot;${commands [@]}&quot;<\/code>\u00a0command prints each command output on a separate line. The output is then piped <code class=\"\" data-line=\"\">|<\/code> to <strong>xargs<\/strong>, which reads the input lines &amp; executes the command <code class=\"\" data-line=\"\">sh -c &quot;{}&quot;<\/code> in parallel. And, this command instructs the shell interpreter to execute the command represented by <code class=\"\" data-line=\"\">{}<\/code> will be replaced by each command from the array as <strong>xargs <\/strong>processes them.<\/div><\/div><img decoding=\"async\" class=\"aligncenter size-full wp-image-14126\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Run-Commands-in-parallel-with-xargs.png\" alt=\"Run bash commands in parallel with the xargs command\" width=\"825\" height=\"453\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Run-Commands-in-parallel-with-xargs.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Run-Commands-in-parallel-with-xargs-300x165.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/5.-Run-Commands-in-parallel-with-xargs-767x421.png 767w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/> The script prints all three commands&#8217; output upon execution along with the <strong>All commands completed <\/strong>message after all the operations are done.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Importance_of_Running_Bash_Commands_in_Parallel\"><\/span>Importance of Running Bash Commands in Parallel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Check out the significant outcomes you can get while running several Bash commands in parallel:<\/p>\n<ul>\n<li style=\"text-align: justify;\">By running commands in parallel, you can take the benefits of multicore processes and execute tasks concurrently. And that reduces overall execution time.<\/li>\n<li style=\"text-align: justify;\">When writing scripts or automation takes place, running commands in parallel within <strong>Bash <\/strong>scripts can increase efficiency ensuring faster execution.<\/li>\n<li style=\"text-align: justify;\">You can process a large number of files and even a complex command that takes a long time to execute.<\/li>\n<li style=\"text-align: justify;\">Improve the performance of a Bash script that is running on a single <strong>CPU<\/strong>.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In conclusion, learning to run several <strong>Bash<\/strong> commands in parallel can enhance your <strong>Bash <\/strong>scripting experience with speed, performance, &amp; efficiency. Using some simple commands you can make it possible. I hope this article helps you learn the entire process.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Does_bash_run_in_parallel\"><\/span>Does bash run in parallel?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>Bash<\/strong> is primarily designed for the sequential execution of commands. That means, out of multiple commands, the first one will be executed first &amp;<strong> Bash<\/strong> will wait for it to end before the next command. However, using certain operators &amp; commands you can commands in parallel within a <strong>Bash<\/strong> script.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_do_I_run_two_shell_commands_in_parallel\"><\/span>How do I run two shell commands in parallel?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To run two shell commands in parallel, you can use the <strong>and <\/strong><code class=\"\" data-line=\"\">&amp;<\/code> operator to start a command in the background. This allows both commands to run simultaneously. For example, use command syntax, <code class=\"\" data-line=\"\">command1 &amp; command2 &amp;<\/code>.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_to_do_parallel_execution_in_bash_script\"><\/span>How to do parallel execution in bash script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To achieve parallel execution of multiple commands within a <strong>Bash <\/strong>script, you can use the <strong>\u2018&amp;\u2019<\/strong> operator to start each command in the background and then use the<strong> \u2018wait\u2019<\/strong> command to wait for all background processes to finish.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_do_I_run_a_bash_command_on_multiple_lines\"><\/span>How do I run a bash command on multiple lines?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In <strong>Bash,<\/strong> you can run a command on multiple lines by using a <strong>backlash <\/strong><code class=\"\" data-line=\"\">\\<\/code>\u00a0to indicate line continuation. Moreover, this allows you to break a long command into multiple lines for better readability.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"Does bash run in parallel?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Bash is primarily designed for the sequential execution of commands. That means, out of multiple commands, the first one will be executed first & Bash will wait for it to end before the next command. However, using certain operators & commands you can commands in parallel within a Bash script.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How do I run two shell commands in parallel?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To run two shell commands in parallel, you can use the and (\u2018&\u2019) operator to start a command in the background. This allows both commands to run simultaneously. For example, use command syntax, command1 & command2 &.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How to do parallel execution in bash script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To achieve parallel execution of multiple commands within a Bash script, you can use the \u2018&\u2019 operator to start each command in the background and then use the \u2018wait\u2019 command to wait for all background processes to finish.\"\n    }\n  }]\n}\n<\/script><br \/>\n<span style=\"font-size: 18pt; color: #003366;\"><strong>Related Articles<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/make-file-executable\/\" target=\"_blank\" rel=\"noopener\">How to make a File Executable in Bash [2 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/dot-command\/\" target=\"_blank\" rel=\"noopener\">A Complete Overview of Bash Dot Command [With 2 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/source\/\" target=\"_blank\" rel=\"noopener\">What are the Usages of Bash Source [3 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-a-script\/\" target=\"_blank\" rel=\"noopener\">How to Run a Bash Script [2 Methods with Cases]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Executing Bash Script&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1065857,&quot;3&quot;:{&quot;1&quot;:0},&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/\" target=\"_blank\" rel=\"noopener\">Executing Bash Script<\/a><\/span> | <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Basics&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:16768,&quot;10&quot;:1,&quot;11&quot;:4,&quot;17&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Basics<\/a> <\/span>| <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;14115&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;15&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;4.7&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;4.7\\\/5 - (15 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;How to Run Bash Commands in Parallel [4 Ways With Examples]&quot;,&quot;width&quot;:&quot;133.8&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 133.8px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            4.7\/5 - (15 votes)    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Running Bash commands in parallel is a technique or method of executing multiple commands simultaneously in a Bash shell environment. &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Run Bash Commands in Parallel [4 Ways With Examples]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#more-14115\" aria-label=\"Read more about How to Run Bash Commands in Parallel [4 Ways With Examples]\">Read more<\/a><\/p>\n","protected":false},"author":314897,"featured_media":14127,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[113],"class_list":["post-14115","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-executing-bash-script","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Run Bash Commands in Parallel [4 Ways With Examples]<\/title>\n<meta name=\"description\" content=\"In Bash scripting, you can run commands in parallel by using some operators &amp; commands. Parallel execution reduces overall execution time.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Run Bash Commands in Parallel [4 Ways With Examples]\" \/>\n<meta property=\"og:description\" content=\"In Bash scripting, you can run commands in parallel by using some operators &amp; commands. Parallel execution reduces overall execution time.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/moniramunny05\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T07:27:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-12T07:53:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Monira Akter Munny\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Monira Akter Munny\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/\"},\"author\":{\"name\":\"Monira Akter Munny\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/2d8ccee92571d892b55ef5999761fc9e\"},\"headline\":\"How to Run Bash Commands in Parallel [4 Ways With Examples]\",\"datePublished\":\"2023-07-25T07:27:34+00:00\",\"dateModified\":\"2024-02-12T07:53:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/\"},\"wordCount\":1277,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-run-commands-in-parallel.png\",\"keywords\":[\"executing bash script\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/\",\"name\":\"How to Run Bash Commands in Parallel [4 Ways With Examples]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-run-commands-in-parallel.png\",\"datePublished\":\"2023-07-25T07:27:34+00:00\",\"dateModified\":\"2024-02-12T07:53:57+00:00\",\"description\":\"In Bash scripting, you can run commands in parallel by using some operators & commands. Parallel execution reduces overall execution time.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-run-commands-in-parallel.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/bash-run-commands-in-parallel.png\",\"width\":400,\"height\":400,\"caption\":\"bash run commands in parallel\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/run-commands-in-parallel\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash Scripting Tutorial\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bash Scripting Basics\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Executing Bash script\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/executing\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to Run Bash Commands in Parallel [4 Ways With Examples]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/2d8ccee92571d892b55ef5999761fc9e\",\"name\":\"Monira Akter Munny\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Monira-Akter-Munny-II-96x96.png\",\"caption\":\"Monira Akter Munny\"},\"description\":\"Hello!! This is Monira Akter Munny. I'm a Linux content developer executive here, at SOFTEKO company. I have completed my B.Sc. in Engineering from Rajshahi University of Engineering &amp; Technology in the Electrical &amp; Electronics department. I'm more of an online gaming person who also loves to read blogs &amp; write. As an open-minded person ready to learn &amp; adapt to new territory, I'm always excited to explore the Linux world &amp; share it with you! Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/moniramunny05\",\"https:\\\/\\\/www.instagram.com\\\/monira_munny\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/monira-akter-munny-a76742113\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/munny\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Run Bash Commands in Parallel [4 Ways With Examples]","description":"In Bash scripting, you can run commands in parallel by using some operators & commands. Parallel execution reduces overall execution time.","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:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/","og_locale":"en_US","og_type":"article","og_title":"How to Run Bash Commands in Parallel [4 Ways With Examples]","og_description":"In Bash scripting, you can run commands in parallel by using some operators & commands. Parallel execution reduces overall execution time.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/moniramunny05","article_published_time":"2023-07-25T07:27:34+00:00","article_modified_time":"2024-02-12T07:53:57+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png","type":"image\/png"}],"author":"Monira Akter Munny","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Monira Akter Munny","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/"},"author":{"name":"Monira Akter Munny","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/2d8ccee92571d892b55ef5999761fc9e"},"headline":"How to Run Bash Commands in Parallel [4 Ways With Examples]","datePublished":"2023-07-25T07:27:34+00:00","dateModified":"2024-02-12T07:53:57+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/"},"wordCount":1277,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png","keywords":["executing bash script"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/","name":"How to Run Bash Commands in Parallel [4 Ways With Examples]","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png","datePublished":"2023-07-25T07:27:34+00:00","dateModified":"2024-02-12T07:53:57+00:00","description":"In Bash scripting, you can run commands in parallel by using some operators & commands. Parallel execution reduces overall execution time.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/bash-run-commands-in-parallel.png","width":400,"height":400,"caption":"bash run commands in parallel"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/run-commands-in-parallel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Bash Scripting Tutorial","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/"},{"@type":"ListItem","position":3,"name":"Bash Scripting Basics","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/"},{"@type":"ListItem","position":4,"name":"Executing Bash script","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/executing\/"},{"@type":"ListItem","position":5,"name":"How to Run Bash Commands in Parallel [4 Ways With Examples]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/2d8ccee92571d892b55ef5999761fc9e","name":"Monira Akter Munny","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Monira-Akter-Munny-II-96x96.png","caption":"Monira Akter Munny"},"description":"Hello!! This is Monira Akter Munny. I'm a Linux content developer executive here, at SOFTEKO company. I have completed my B.Sc. in Engineering from Rajshahi University of Engineering &amp; Technology in the Electrical &amp; Electronics department. I'm more of an online gaming person who also loves to read blogs &amp; write. As an open-minded person ready to learn &amp; adapt to new territory, I'm always excited to explore the Linux world &amp; share it with you! Read Full Bio","sameAs":["https:\/\/www.facebook.com\/moniramunny05","https:\/\/www.instagram.com\/monira_munny\/","https:\/\/www.linkedin.com\/in\/monira-akter-munny-a76742113\/"],"url":"https:\/\/linuxsimply.com\/author\/munny\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314897"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=14115"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14115\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/14127"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=14115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=14115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=14115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}