I see $1, $2, $3 and such values in shell script. What is $1, $2 in Linux shell script?
Linux and Unix shell scripts can use unique variables. For example, you can use the following inputs in your shell scripts:
-
$0
- The name of the script. -
$1
- The first command-line argument passed to the script. -
$2
- The second command-line argument passed to the script.
Example
#!/bin/bash
script="$0"
first="$1"
second="$2"
tenth="${10}"
echo "The script name : $script"
echo "The first argument : $first"
echo "The second argument : $second"
echo "The tenth and eleventh argument : $tenth and ${11}"
See $1 - Linux Bash Shell Scripting Tutorial Wiki and Pass arguments into a function - Linux Bash Shell Scripting Tutorial Wiki for more info.