Special Variables
$0 is the script name, $1 to $9 are arguments, $# counts them, $@ lists them, $? is the last exit code and $$ is the process id.
Example
set -- one two three
echo "$#: $1 $2"
echo "all: $@"
ls /nonexistent 2>/dev/null
echo "exit code $?"
true
echo "exit code $?"Result
3: one two all: one two three exit code 2 exit code 0
Exercise
Number of arguments.
echo #
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.