Description
The shell command and any arguments to that command appear as numbered shell variables. $0 has the string value of the command itself. Any arguments passed after the script appear as $1, $2, $3 and so on. The count of arguments is in the shell variable $#.[1] [2]
Example
Execute a script from the CLI followed by an argument,
1 | $ ./script.sh <argument1> <argument2> <argument2> |
Sample contents of script.sh:
1 | #!/usr/bin/env bash |
In this example $1 would have the value of the first argument given at the command line during script execution.