Where n is a positive integer and takes values from 1 to a greater value not restricted.

n correspond to the position of an argument givent to a script or to a function


myfunc() {
    echo "argument 1 = $1"
    echo "argument 2 = $2"
myfunc 10 20

# Output will be:
argument 1 = 10
argument 2 = 20


Exit status of the last command executed
The $? of the current process/script is limited either to the exit status or to the result of the last command executed by this script. So, if your last script line is the call to that function, and that function returns 50, the $? that you produce to the process that called you is 50

Create a script script_func1.sh


myfunc1() {
    echo "hello from myfunc1"
    return 10

echo $?
$> # execute this script:
$> ./script_func1.sh
hello from myfunc1

Now create a script called script_func2.sh:


echo "hello from script_func2"
exit 0
$> # execute this script:
$> ./script_func2.sh
hello from script_func2
$> echo $?


The process ID of the current shell. For shell scripts, this is the process ID under which they are executing.


The filename of the current script.


The number of arguments supplied to a script.


The process ID of the last background command.

It will work if you call a background command like this:

$> echo "hello" &
[1] 748
[1]+  Done                    builtin echo "a"
$> echo $!
$> # now we try another way
$> (echo "hello2" &)
$> echo $!

As you can see the process ID of the second background call isn’t seen because it’s detached from the current session (like with the nohup command).