{"id":40154,"date":"2024-04-02T09:57:11","date_gmt":"2024-04-02T09:57:11","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=40154"},"modified":"2024-04-23T04:03:22","modified_gmt":"2024-04-23T04:03:22","slug":"bash-argument-list-too-long","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/","title":{"rendered":"[Solved] \u201cbash: Argument list too long\u201d Error"},"content":{"rendered":"<p style=\"text-align: justify;\">The \u201cArgument list too long\u201d is an error in Bash shell. Users often encounter the error while executing commands with too many arguments. This error particularly occurs while attempting to delete, move, or copy too many files at once. The aim of this article is to explain the reason that triggers the \u201cArgument list too long\u201d error. Moreover, the article will discuss the available solutions to overcome the error.<\/p>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/Practice-Files_bash-argument-list-too-long.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> Files of \u201cArgument list too long\u201d Error in Bash<\/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\/functions\/script-argument\/argument-list-too-long\/#What_is_%E2%80%9CArgument_list_too_long%E2%80%9D_Error_in_Bash\" >What is &#8220;Argument list too long&#8221; Error in Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#Scenarios_That_Trigger_Bash_%E2%80%9CArgument_list_too_long%E2%80%9D_Error\" >Scenarios That Trigger Bash &#8220;Argument list too long&#8221; Error<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#3_Ways_to_fix_%E2%80%9CArgument_list_too_long%E2%80%9D_Error_in_Bash\" >3 Ways to fix \u201cArgument list too long\u201d Error in Bash<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#1_Using_the_%E2%80%9Cxargs%E2%80%9D_Command\" >1. Using the \u201cxargs\u201d 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\/functions\/script-argument\/argument-list-too-long\/#2_With_a_For_Loop\" >2. With a For Loop<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#3_By_Manual_Splitting\" >3. By Manual Splitting<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#Remove_All_the_Content_of_a_Directory\" >Remove All the Content of a Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#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-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#How_to_simulate_the_%E2%80%9CArgument_list_too_long%E2%80%9D_error_in_Bash\" >How to simulate the &#8220;Argument list too long&#8221; error in Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#How_do_you_resolve_the_%E2%80%9CArgument_list_too_long%E2%80%9D_error_in_Bash\" >How do you resolve the &#8220;Argument list too long&#8221; error in Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#How_do_I_avoid_%E2%80%9CArgument_list_too_long%E2%80%9D_errors_when_compressing_thousands_of_files\" >How do I avoid &#8220;Argument list too long&#8221; errors when compressing thousands of files?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#How_do_I_delete_too_many_files_in_Bash\" >How do I delete too many files in Bash?<\/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\/functions\/script-argument\/argument-list-too-long\/#What_is_the_maximum_number_of_arguments_in_a_Bash_script\" >What is the maximum number of arguments in a Bash script?<\/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\/functions\/script-argument\/argument-list-too-long\/#What_is_the_exact_limit_of_arguments_to_avoid_%E2%80%9CArgument_list_too_long%E2%80%9D_error\" >What is the exact limit of arguments to avoid &#8220;Argument list too long&#8221; error?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_is_%E2%80%9CArgument_list_too_long%E2%80%9D_Error_in_Bash\"><\/span>What is &#8220;Argument list too long&#8221; Error in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">The<strong> &#8220;<\/strong>Argument list too long<strong>&#8220;<\/strong> error in Bash occurs when attempting to execute a command that involves passing a large number of arguments. This error usually arises when the total length of arguments passed to a command exceeds a certain limit. This limit is determined by the shell&#8217;s buffer size. If the number of arguments passed to a command is greater than the argument buffer space then Bash can\u2019t handle the long list of arguments and raises the &#8220;Argument list too long&#8221; error.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Scenarios_That_Trigger_Bash_%E2%80%9CArgument_list_too_long%E2%80%9D_Error\"><\/span>Scenarios That Trigger Bash &#8220;Argument list too long&#8221; Error<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Various scenarios can trigger the &#8220;Argument list too long&#8221; error in Bash. However, the root cause remains the same for all cases. Even users can end up with this error while using popular commands such as rm, cp, mv etc.<\/p>\n<p style=\"text-align: justify;\">To simulate the error and show you the reason for the error, a folder <strong>temp<\/strong> is created using the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">mkdir temp<\/code><\/pre>\n<p style=\"text-align: justify;\">All the demonstrations of this article are shown in the <strong>temp<\/strong> folder. Now, change the current directory to the temp folder using the <a href=\"https:\/\/linuxsimply.com\/cd-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>cd command<\/strong><\/a>:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">cd temp<\/code><\/pre>\n<p style=\"text-align: justify;\">At this point, a huge number of files let\u2019s say- 240k are created with the following Bash script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nfor i in {1..240000}; do\n touch file&quot;$i&quot;.txt;\ndone<\/code><\/pre>\n<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\">\n<p>The simple <strong>for loop<\/strong> of the Bash script iterates from 1 to 240,000 using <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/expansion\/brace-expansion\/#:~:text=Brace%20expansion%20is%20a%20feature,in%20many%20other%20useful%20contexts.\" target=\"_blank\" rel=\"noopener\"><strong>brace expansion<\/strong><\/a> <code class=\"\" data-line=\"\">{1..240000}<\/code>. Within each iteration, the <strong>touch <\/strong>command is executed to create a new empty file with a filename formatted as <code class=\"\" data-line=\"\">file&quot;$i&quot;.txt<\/code>, where <code class=\"\" data-line=\"\">$i<\/code> represents the current iteration number. Essentially, this script automates the creation of 240,000 text files in the current directory, each named sequentially from &#8220;file1.txt&#8221; to &#8220;file240000.txt&#8221;.<\/p>\n<\/div><\/div>\n<p style=\"text-align: justify;\">Check how many files are there in the temp directory with the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">ls -lrt | wc -l<\/code><\/pre>\n<p style=\"text-align: justify;\">This command lists the contents of the current directory in a long format, sorted by modification time with the newest files last, and then counts the number of lines in that output. This effectively gives you the total number of files (including sub-directories) in the current directory.<\/p>\n<p style=\"text-align: justify;\">Now, deleting all the files of this directory using the <a href=\"https:\/\/linuxsimply.com\/rm-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>rm command<\/strong><\/a> raises the &#8220;Argument list too long&#8221; error. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">rm *.txt<\/code><\/pre>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-40155\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/1.-Simulating-argument-list-too-long-error-in-Bash.png\" alt=\"Simulating argument list too long error in Bash\" width=\"698\" height=\"165\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/1.-Simulating-argument-list-too-long-error-in-Bash.png 698w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/1.-Simulating-argument-list-too-long-error-in-Bash-300x71.png 300w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/p>\n<p style=\"text-align: justify;\">This happens because the shell expands <code class=\"\" data-line=\"\">*<\/code> to match all files (&#8220;file1.txt&#8221;, &#8220;file2.txt&#8221; \u2026 &#8220;file240000.txt&#8221;), and the resulting command becomes:<\/p>\n<p><code class=\"\" data-line=\"\">rm file1.txt file2.txt file3.txt file4.txt ... file240000.txt<\/code><\/p>\n<p style=\"text-align: justify;\">In this case, the argument list becomes equivalent to the number of files in the temp directory, which is 240,000 files. This results in a long list of arguments and crosses the limit of arguments.<\/p>\n<p style=\"text-align: justify;\">To get the limit of arguments that the current system allows, utilize the getconf command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">getconf ARG_MAX<\/code><\/pre>\n<p style=\"text-align: justify;\">It doesn&#8217;t give the number of arguments directly but provides the maximum length of the arguments that can be passed to a command in bytes.<img decoding=\"async\" class=\"aligncenter size-full wp-image-40156\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/2.-Getting-the-maximum-argument-limit-using-ARG_MAX.png\" alt=\"Getting the maximum argument limit using ARG_MAX\" width=\"539\" height=\"120\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/2.-Getting-the-maximum-argument-limit-using-ARG_MAX.png 539w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/2.-Getting-the-maximum-argument-limit-using-ARG_MAX-300x67.png 300w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/> The output indicates the maximum size of all arguments combined for the current system is <strong>2097152<\/strong> bytes.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"3_Ways_to_fix_%E2%80%9CArgument_list_too_long%E2%80%9D_Error_in_Bash\"><\/span>3 Ways to fix \u201cArgument list too long\u201d Error in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">There are multiple ways to overcome the \u201cArgument list too long\u201d error in Bash. You can use the xargs command and for loop to make the argument list shorter for each execution. Moreover, manually splitting the long list of arguments also fixes the problem. The following discussion explains some of the solutions in detail.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Using_the_%E2%80%9Cxargs%E2%80%9D_Command\"><\/span>1. Using the \u201cxargs\u201d Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To fix \u201cArgument list too long\u201d error in Bash, use the <a href=\"https:\/\/linuxsimply.com\/xargs-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>xargs command<\/strong><\/a>. For instance, if you want to delete a long list of files at a time, simply the rm command can\u2019t handle it. However, the xargs command can execute commands such as the rm command on chunks of files, avoiding the &#8220;Argument list too long&#8221; error. Look at the example of deleting 240000 files:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">find . -iname &quot;file*&quot; | xargs rm<\/code><\/pre>\n<p style=\"text-align: justify;\">Here, the <a href=\"https:\/\/linuxsimply.com\/find-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>find command<\/strong><\/a> is used to match 240000 files from \u201cfile1.txt\u201d to \u201cfile240000.txt\u201d. After that, these files are <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/redirection-and-piping\/piping\/#:~:text=Piping%20in%20a%20shell%2C%20such,flow%20of%20data%20between%20commands.\" target=\"_blank\" rel=\"noopener\"><strong>piped<\/strong><\/a> to xargs to execute the rm command on each file.<img decoding=\"async\" class=\"aligncenter size-full wp-image-40157\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/3.-xargs-to-avoid-argument-list-too-long-error-in-Bash.png\" alt=\"xargs to avoid argument list too long error in Bash\" width=\"700\" height=\"135\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/3.-xargs-to-avoid-argument-list-too-long-error-in-Bash.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/3.-xargs-to-avoid-argument-list-too-long-error-in-Bash-300x58.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/> After executing the command, the <strong>temp <\/strong>folder becomes empty and the <a href=\"https:\/\/linuxsimply.com\/ls-command-in-linux\/#:~:text=ls%20is%20a%20popular%20shell,using%20different%20options%20with%20it.\" target=\"_blank\" rel=\"noopener\"><strong>ls command<\/strong><\/a> can\u2019t find anything to list.<\/p>\n<div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\">\n<p style=\"text-align: justify;\"><strong>Note:<\/strong> xargs treats whitespace and quote characters as delimiters. Therefore, the xargs command may cause serious issues while handling filenames containing such characters.<\/div><\/div>\n<p style=\"text-align: justify;\">Learn that,<code class=\"\" data-line=\"\"> xargs --show-limits<\/code> displays the system limits for the number of arguments and the maximum size of the command line that xargs can handle. This information can be helpful for understanding the limitations when using xargs to process commands with a large number of arguments. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">xargs \u2013show-limits<\/code><\/pre>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40158\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/4.-Showing-the-limits-of-xargs.png\" alt=\"Showing the limits of xargs\" width=\"825\" height=\"159\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/4.-Showing-the-limits-of-xargs.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/4.-Showing-the-limits-of-xargs-300x58.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/4.-Showing-the-limits-of-xargs-768x148.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>The image shows lots of information. Most importantly it displays that the \u2018upper limit on argument length\u2019 is <strong>2091737<\/strong> <strong>bytes<\/strong> for this system. It means Bash can allocate 2091737 bytes at max for arguments of a command while using xargs.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_With_a_For_Loop\"><\/span>2. With a For Loop<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/loop\/for-loop\/\" target=\"_blank\" rel=\"noopener\"><strong>For loop<\/strong><\/a> is another way to fix the \u201cArgument list too long\u201d error in Bash. Think about the files of <strong>temp<\/strong> directory. Instead of deleting all the files at once, a for loop can iterate over the files and delete them one by one as follows:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nfor f in file*; do\n rm &quot;$f&quot;\ndone\necho &quot;All the files are deleted.&quot;<\/code><\/pre>\n<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\">\n<p>The Bash script iterates over files of the current directory whose names start with &#8220;file&#8221; using the wildcard pattern <code class=\"\" data-line=\"\">file*<\/code>. For each file found by the <strong>for loop<\/strong> is stored in the variable <code class=\"\" data-line=\"\">f<\/code>. <code class=\"\" data-line=\"\">rm &quot;$f&quot;<\/code> deletes one file in each iteration. After deleting all the matched files the script displays a message &#8220;All the files are deleted.&#8221;.<\/p>\n<\/div><\/div>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40159\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/5.-For-loop-to-avoid-argument-list-too-long-error-in-Bash.png\" alt=\"For loop to avoid argument list too long error in Bash\" width=\"477\" height=\"134\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/5.-For-loop-to-avoid-argument-list-too-long-error-in-Bash.png 477w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/5.-For-loop-to-avoid-argument-list-too-long-error-in-Bash-300x84.png 300w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><\/p>\n<p style=\"text-align: justify;\">After executing the script, the <strong>ls<\/strong> command can\u2019t find any file that matches the pattern \u201cfile*\u201d.\u00a0 Though this approach of handling a long list of arguments is slower, it effectively fixes the issue.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_By_Manual_Splitting\"><\/span>3. By Manual Splitting<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">A brute-force approach to avoid the \u201cArgument list too long\u201d error in Bash involves manually splitting the arguments into smaller batches. For instance, &#8220;file1.txt&#8221; to &#8220;file240000.txt&#8221; can be divided into four groups and necessary commands can be executed on the smaller bunches.<\/p>\n<p style=\"text-align: justify;\">Check below how manual splitting avoids \u201cArgument list too long\u201d error while deleting 240k files from the temp folder:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">rm file{1..60000}.txt\nrm file{60001..120000}.txt\nrm file{120001..180000}.txt\nrm file{180001..240000}.txt<\/code><\/pre>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40160\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/6.-Manual-splitting-of-arguments-to-avoid-argument-list-too-long-in-Bash.png\" alt=\"Manual splitting of arguments to avoid argument list too long in Bash\" width=\"700\" height=\"153\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/6.-Manual-splitting-of-arguments-to-avoid-argument-list-too-long-in-Bash.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/6.-Manual-splitting-of-arguments-to-avoid-argument-list-too-long-in-Bash-300x66.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/>Though a single rm command fails to delete <strong>240k<\/strong> files at a time, dividing the files into <strong>four groups<\/strong> and executing rm on those removes all the files from the directory.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Remove_All_the_Content_of_a_Directory\"><\/span>Remove All the Content of a Directory<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In case deleting all the files of a directory causes the \u201cArgument list too long\u201d error, an alternative solution is removing the entire directory instead of deleting the files. For example, delete the already created temp folder and recreate it again with the following commands:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">cd .. &amp;&amp; rm -rf \/home\/laku\/temp\ncd home\/laku &amp;&amp; mkdir temp &amp;&amp; home\/laku\/temp<\/code><\/pre>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-40161\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/7.-Removing-entire-directory-and-recreate-it-again-to-avoid-argument-list-too-long-in-Bash.png\" alt=\"Removing entire directory and recreate it again to avoid argument list too long in Bash\" width=\"825\" height=\"102\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/7.-Removing-entire-directory-and-recreate-it-again-to-avoid-argument-list-too-long-in-Bash.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/7.-Removing-entire-directory-and-recreate-it-again-to-avoid-argument-list-too-long-in-Bash-300x37.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/7.-Removing-entire-directory-and-recreate-it-again-to-avoid-argument-list-too-long-in-Bash-768x95.png 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>Both commands use <code class=\"\" data-line=\"\">&amp;&amp;<\/code> to execute two commands at once. The first command changes the current directory to the parent directory of temp and then removes the directory. Then the second command creates the temp folder again and changes the current directory to temp. This way all the files of the temp folder have been deleted and a new temp folder has been created.<\/p>\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;\">To sum up, the \u201cArgument list too long\u201d error is a common issue in Bash while working with a large number of arguments passed to a command. Its solutions are pretty straightforward once you understand the reason behind it. You can handle the error effectively using commands such as \u201cxargs\u201d or employing loops to process the arguments one by one. I believe that from now on, you can easily choose the proper solution to handle the error when you encounter it.<\/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><span class=\"ez-toc-section\" id=\"How_to_simulate_the_%E2%80%9CArgument_list_too_long%E2%80%9D_error_in_Bash\"><\/span>How to simulate the &#8220;Argument list too long&#8221; error in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To simulate the &#8220;Argument list too long&#8221; error in Bash, you can use brace expansion to create a large number of files with sequential names. For instance, try to execute the following command to create 240k files:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">touch file{1..240000}.txt<\/code><\/pre>\n<p style=\"text-align: justify;\">This will raise &#8220;Argument list too long&#8221; error. If it doesn\u2019t, gradually increase the range until the error occurs.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_you_resolve_the_%E2%80%9CArgument_list_too_long%E2%80%9D_error_in_Bash\"><\/span>How do you resolve the &#8220;Argument list too long&#8221; error in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To resolve the &#8220;Argument list too long&#8221; error in Bash, you have a few options:<\/p>\n<ol>\n<li style=\"text-align: justify;\"><strong>xargs command<\/strong>: Instead of passing all arguments directly to a command, you can use the xargs command to pass them in manageable chunks.<\/li>\n<li style=\"text-align: justify;\"><strong>loop<\/strong>: Use Bash for loop to iterate over each argument and perform the operation on each file individually.<\/li>\n<li style=\"text-align: justify;\"><strong>Manual splitting<\/strong>: Manually split the argument list into multiple groups and perform the required operation on each group.<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"How_do_I_avoid_%E2%80%9CArgument_list_too_long%E2%80%9D_errors_when_compressing_thousands_of_files\"><\/span>How do I avoid &#8220;Argument list too long&#8221; errors when compressing thousands of files?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can avoid &#8220;Argument list too long&#8221; errors when compressing thousands of files by using the <strong>find<\/strong> command. Here&#8217;s an example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">find . -name &quot;*.xml&quot; -print | tar -czvf xml.tgz -T -<\/code><\/pre>\n<p style=\"text-align: justify;\">This command will find all files with a .xml extension in the current directory and its subdirectories, safely pass their names to <strong>tar<\/strong>, and then compress them into xml.tgz.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_I_delete_too_many_files_in_Bash\"><\/span>How do I delete too many files in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">To delete too many files in Bash, you can use the find command with exec. Here&#8217;s a general example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">find \/path\/to\/files -type f -name &quot;pattern&quot; -exec rm {} +<\/code><\/pre>\n<p style=\"text-align: justify;\">Replace <strong>\/path\/to\/files<\/strong> with the directory containing the files you want to delete and <strong>&#8220;pattern&#8221;<\/strong> with the filename pattern or expression you want to match. This command will find all files matching the pattern and delete them efficiently.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_maximum_number_of_arguments_in_a_Bash_script\"><\/span>What is the maximum number of arguments in a Bash script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">There&#8217;s no single, definitive answer to the maximum number of arguments in a Bash script. Bash has a limitation on the overall length of arguments of a command. You can use the <code class=\"\" data-line=\"\">getconf ARG_MAX<\/code> to find the maximum size of arguments in bytes.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_exact_limit_of_arguments_to_avoid_%E2%80%9CArgument_list_too_long%E2%80%9D_error\"><\/span>What is the exact limit of arguments to avoid &#8220;Argument list too long&#8221; error?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The exact limit of arguments to avoid the &#8220;Argument list too long&#8221; error can vary depending on the system. However, a common limit is typically around 128 KB to 2 MB for total argument length. This limit includes not only the length of each individual argument but also the overhead of the command itself and any environment variables. It&#8217;s important to note that this limit is not a fixed number of arguments but rather a limit on the total length of all arguments combined. Therefore, the actual number of arguments that will trigger the error can vary based on the length of each argument.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"How to simulate the Argument list too long error in Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To simulate the Argument list too long error in Bash, you can use brace expansion to create a large number of files with sequential names. For instance, try to execute the following command to create 240k files:<\/p>\n<p>touch file{1..240000}.txt<\/p>\n<p>This will raise Argument list too long error. If it doesn\u2019t, gradually increase the range until the error occurs.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How do you resolve the Argument list too long error in Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To resolve the Argument list too long error in Bash, you have a few options:<\/p>\n<p>xargs command: Instead of passing all arguments directly to a command, you can use the xargs command to pass them in manageable chunks.<\/p>\n<p>loop: Use Bash for loop to iterate over each argument and perform the operation on each file individually.<\/p>\n<p>Manual splitting: Manually split the argument list into multiple groups and perform the required operation on each group.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How do I avoid Argument list too long errors when compressing thousands of files?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"You can avoid \\\"Argument list too long\\\" errors when compressing thousands of files by using the find command. Here's an example:<\/p>\n<p>find . -name \\\"*.xml\\\" -print | tar -czvf xml.tgz -T -<\/p>\n<p>This command will find all files with a .xml extension in the current directory and its subdirectories, safely pass their names to tar, and then compress them into xml.tgz.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How do I delete too many files in Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To delete too many files in Bash, you can use the find command with exec. Here's a general example:<\/p>\n<p>find \/path\/to\/files -type f -name \\\"pattern\\\" -exec rm {} +<\/p>\n<p>Replace \/path\/to\/files with the directory containing the files you want to delete and \\\"pattern\\\" with the filename pattern or expression you want to match. This command will find all files matching the pattern and delete them efficiently.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is the maximum number of arguments in a Bash script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"There's no single, definitive answer to the maximum number of arguments in a Bash script. Bash has a limitation on the overall length of arguments of a command. You can use the getconf ARG_MAX to find the maximum size of arguments in bytes.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is the exact limit of arguments to avoid Argument list too long error?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The exact limit of arguments to avoid the Argument list too long error can vary depending on the system. However, a common limit is typically around 128 KB to 2 MB for total argument length. This limit includes not only the length of each individual argument but also the overhead of the command itself and any environment variables. It's important to note that this limit is not a fixed number of arguments but rather a limit on the total length of all arguments combined. Therefore, the actual number of arguments that will trigger the error can vary based on the length of each argument.\"\n    }\n  }]\n}\n<\/script><\/p>\n<p><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\/functions\/script-argument\/number-of-args\/\" target=\"_blank\" rel=\"noopener\">How to Check Number of Arguments in Bash? [3 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/first-argument\/\" target=\"_blank\" rel=\"noopener\">How to Use First Argument in Bash Script [5 Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/get-argument\/\" target=\"_blank\" rel=\"noopener\">How to Get Argument in Bash? [4 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/pass-arguments\/\" target=\"_blank\" rel=\"noopener\">How to Pass Arguments to Bash Script? [5 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/optional-arguments\/\" target=\"_blank\" rel=\"noopener\">How to Parse Optional Arguments in Bash Script [2 Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/pass-array-to-function\/\" target=\"_blank\" rel=\"noopener\">How to Pass Array as an Argument in Bash Function? [3 Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/default-argument\/\" target=\"_blank\" rel=\"noopener\">How to Set Default Argument in Bash [2 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/bash-optarg\/\" target=\"_blank\" rel=\"noopener\">How to Use OPTARG in Bash [3 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/bash-getopts\/\" target=\"_blank\" rel=\"noopener\">How to Use \u201cgetopts\u201d in Bash [Complete Guide]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Argument in Bash Script&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/\" target=\"_blank\" rel=\"noopener\">Argument in Bash Script<\/a><\/span> | <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Functions&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/\" target=\"_blank\" rel=\"noopener\">Bash Functions<\/a><\/span> | <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Tutorial&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/span><\/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;40154&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;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&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;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;[Solved] \u201cbash: Argument list too long\u201d Error&quot;,&quot;width&quot;:&quot;0&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: 0px;\">\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            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The \u201cArgument list too long\u201d is an error in Bash shell. Users often encounter the error while executing commands with &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"[Solved] \u201cbash: Argument list too long\u201d Error\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#more-40154\" aria-label=\"Read more about [Solved] \u201cbash: Argument list too long\u201d Error\">Read more<\/a><\/p>\n","protected":false},"author":314903,"featured_media":40162,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[202],"class_list":["post-40154","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-bash-script-argument","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>[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply<\/title>\n<meta name=\"description\" content=\"&quot;Argument list too long&quot; is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.\" \/>\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\/functions\/script-argument\/argument-list-too-long\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"&quot;Argument list too long&quot; is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/zahidlaku72\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-02T09:57:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-23T04:03:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp\" \/>\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\/webp\" \/>\n<meta name=\"author\" content=\"Md Zahidul Islam Laku\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Md Zahidul Islam Laku\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 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\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/\"},\"author\":{\"name\":\"Md Zahidul Islam Laku\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/26b37b2c7517d2c8702472bc3986ef21\"},\"headline\":\"[Solved] \u201cbash: Argument list too long\u201d Error\",\"datePublished\":\"2024-04-02T09:57:11+00:00\",\"dateModified\":\"2024-04-23T04:03:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/\"},\"wordCount\":1900,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/argument-list-too-long-error-in-Bash.webp\",\"keywords\":[\"bash script argument\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/\",\"name\":\"[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/argument-list-too-long-error-in-Bash.webp\",\"datePublished\":\"2024-04-02T09:57:11+00:00\",\"dateModified\":\"2024-04-23T04:03:22+00:00\",\"description\":\"\\\"Argument list too long\\\" is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/argument-list-too-long-error-in-Bash.webp\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/argument-list-too-long-error-in-Bash.webp\",\"width\":400,\"height\":400,\"caption\":\"argument list too long error in Bash\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/argument-list-too-long\\\/#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 Functions\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Argument in Bash Script\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/functions\\\/script-argument\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"[Solved] \u201cbash: Argument list too long\u201d Error\"}]},{\"@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\\\/26b37b2c7517d2c8702472bc3986ef21\",\"name\":\"Md Zahidul Islam Laku\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Md-Zahidul-Islam-Laku-II-96x96.png\",\"caption\":\"Md Zahidul Islam Laku\"},\"description\":\"Hey, I'm Zahidul Islam Laku currently working as a Linux Content Developer Executive at SOFTEKO. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). I write articles on a variety of tech topics including Linux. Learning and writing on Linux is nothing but fun as it gives me more power on my machine. What can be more efficient than interacting with the Operating System without Graphical User Interface! Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/zahidlaku72\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/zahidlaku\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCnxMIaAb-nXO5XnMeEaNhpQ\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/laku\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply","description":"\"Argument list too long\" is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.","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\/functions\/script-argument\/argument-list-too-long\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply","og_description":"\"Argument list too long\" is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/zahidlaku72","article_published_time":"2024-04-02T09:57:11+00:00","article_modified_time":"2024-04-23T04:03:22+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp","type":"image\/webp"}],"author":"Md Zahidul Islam Laku","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Md Zahidul Islam Laku","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/"},"author":{"name":"Md Zahidul Islam Laku","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/26b37b2c7517d2c8702472bc3986ef21"},"headline":"[Solved] \u201cbash: Argument list too long\u201d Error","datePublished":"2024-04-02T09:57:11+00:00","dateModified":"2024-04-23T04:03:22+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/"},"wordCount":1900,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp","keywords":["bash script argument"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/","name":"[Solved] \u201cbash: Argument list too long\u201d Error - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp","datePublished":"2024-04-02T09:57:11+00:00","dateModified":"2024-04-23T04:03:22+00:00","description":"\"Argument list too long\" is an issue Bash users may face. This post talks about the reason for the error as well as its solutions.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2024\/04\/argument-list-too-long-error-in-Bash.webp","width":400,"height":400,"caption":"argument list too long error in Bash"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/argument-list-too-long\/#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 Functions","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/"},{"@type":"ListItem","position":4,"name":"Argument in Bash Script","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/functions\/script-argument\/"},{"@type":"ListItem","position":5,"name":"[Solved] \u201cbash: Argument list too long\u201d Error"}]},{"@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\/26b37b2c7517d2c8702472bc3986ef21","name":"Md Zahidul Islam Laku","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Md-Zahidul-Islam-Laku-II-96x96.png","caption":"Md Zahidul Islam Laku"},"description":"Hey, I'm Zahidul Islam Laku currently working as a Linux Content Developer Executive at SOFTEKO. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). I write articles on a variety of tech topics including Linux. Learning and writing on Linux is nothing but fun as it gives me more power on my machine. What can be more efficient than interacting with the Operating System without Graphical User Interface! Read Full Bio","sameAs":["https:\/\/www.facebook.com\/zahidlaku72","https:\/\/www.linkedin.com\/in\/zahidlaku\/","https:\/\/www.youtube.com\/channel\/UCnxMIaAb-nXO5XnMeEaNhpQ"],"url":"https:\/\/linuxsimply.com\/author\/laku\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/40154","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\/314903"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=40154"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/40154\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/40162"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=40154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=40154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=40154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}