Zend certified PHP/Magento developer

what does ARG_MAX mean when I run a script?

Up to now I know what ARG_MAX means (thanks to EdMorton):

ls foo bar

The command is ls and it has three arguments: foo, and bar. It’s 7 characters, so the arguments of ls in here is 7.

Now let’s suppose this is my script:

#!/usr/bin/bash

while read -r do_something
do
    if [ "$do_something" == "some_string" ]
    then
        echo "do_something $do_something equals to some_string."
    fi
done < some_file

/usr/bin/python3 generate_numbers.py

names="$(awk '{print $4}' another_file.txt)"

awk 'BEGIN { for (i = 1; i <= 5; ++i) print i }'

if [ "$(stat -c %s mail.txt)" -g '0' ]
then
    echo -e "These are mailing list:nn$(cat mail.txt)" | mail -s "Mails List - $(date '+%Y-%m-%d %H:%M')"

Now with the above sample, when I run bash /home/file or /home/file, what’s the arguments counts?

  • Is that wc -c file which is 459 (the shebang is excluded)?
  • Is that for each command? For example the while has 166, /usr/bin/python3 has 20, and so on.

I think it is the second assumption because it’s not logical the first one since I see some huge bash (or any other) scripts which are more than 2097152 in my server (this number is the output of getconf ARG_MAX.