n3rd 1266603212 learn the first positional parameter, equivalent to argv[0] in C, see http://www.bash-hackers.org/wiki/doku.php/scripting/posparams#the_first_argument greycat 1280241997 forget greycat 1280242031 learn $0 is like argv[0] in C. It's whatever the caller decides to put there. You can't rely on it. See http://mywiki.wooledge.org/BashFAQ/028 and http://www.bash-hackers.org/wiki/doku.php/scripting/posparams#the_first_argument Soliton 1649947247 forget Soliton 1649947285 learn $0 is like argv[0] in C. It's whatever the caller decides to put there. You can't rely on it. See http://mywiki.wooledge.org/BashFAQ/028 and https://wiki.bash-hackers.org/scripting/posparams#the_first_argument emanuele6 1729940344 forget emanuele6 1729940876 learn For stdin shells and `sh -c 'code' #no args`, it is value of argv[0] with which the shell was invoked; for `sh -c 'code' foo args...`, it is the value passed after the code (in this example "foo"); for scripts, it is the path to the script as it was passed to sh. See also: https://web.archive.org/web/20230325102835/https://wiki.bash-hackers.org/scripting/posparams#the_first_argument