What is the maximum character length of arguments in a shell command? How do I find out the maximum length of arguments for a new process under Linux or Unix like operating systems?
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. The following command will provide the upper limit for your system under Linux operating systems:
$ getconf ARG_MAX
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 flavours. I recommend that you go through this web page for detailed information.