#!/bin/bash
Echo ' $ "gets the currently executing shell script file name: '" $ "
Echo ' $n gets the nth parameter value of the currently executing shell script, n=1..9 ' $ ' =$1, ' $ $ ' =$2, ' $ $ ' =$3
Echo ' $
get all parameters for the current shell ... Note the difference from [email protected]: ' $
Echo ' $# gets the total number of parameters in the current shell command line: ' $#
Echo ' $$ gets the current shell's process number (PID): ' $$
Sleep 3 &
Echo ' $! PID that executes the previous instruction: ' $!
Echo ' $? Gets the return value of the last instruction executed: ' $?
Echo ' [email protected] Get all the parameters of the current Shell "$" "$" "$" "...": ' [email protected]
Echo ' $
before the last parameter of the command or script: ' $
Eof
SH positional.sh a b c d E
$ A Gets the currently executing shell script file name: positional.sh
$n gets the nth parameter value of the currently executing shell script, n=1..9 $1=a,$2=b,$3=c
$* get all the parameters of the current shell ... Note the difference from [email protected]: a b c D E
$# gets the total number of parameters in the current shell command line: 5
$$ gets the current shell's process number (PID): 1979
$! Executes the pid:1980 of the previous instruction
$? Gets the return value of the last instruction executed: 0
[email protected] Get all the parameters of the current Shell "$" "$" "$" "...": a b C D E
$_ the last parameter of the preceding command or script: E
A script to understand the meaning of positional parameters in a shell script