In PHP, we can pass a variable into script from the file name as file.php?key=value or file.php -key=value. Is there any equivalent option to do so in Shell Script?
I want to run the script in terminal; something like ./file.sh -key=value to pass the variable into the shell script for further processing.
Yes:
value1andvalue2will be exposed to the script in the variables$1and$2; the whole stringvalue1 value2will also show up in$*.You can use the
shiftshell builtin to get one variable at a time.