If you get an error that read as – command: Argument list too long due to limit for the command line length. UNIX / Linux / BSD system has a limit on how many bytes can be used for the command line argument and environment variables. You need to use the getconf command to query system configuration variable called ARG_MAX.
Get maximum length of arguments for a new process
The following command will provide the upper limit for your system under Linux operating systems:
$ getconf ARG_MAX
So I can pass the 2097152 bytes worth args to any shell command. The following bash code will provide you exact number:
echo $(( $(getconf ARG_MAX) - $(env | wc -c) ))
POSIX suggests to subtract 2048 additionally so that the process may savely modify its environment:
expr `getconf ARG_MAX` - `env|wc -c` - `env|wc -l` \* 4 - 2048
Please note that the maximum length of arguments for a new process may differ among unix flavors. I recommend that you go through this web page for detailed information.