#! /bin/bash echo ---------------------------------- echo $0 # the file name echo $1 echo $2 echo $3 echo ---------------------------------- args=($@) # $@ is the reserverd for array input into bash # () the round backets divide it into an array echo Input 0 : ${args[0]} # file name echo Input 1 : ${args[1]} # argument 1 echo Input 2 : ${args[2]} # argument 2 echo Input 3 : ${args[3]} # argument 3 echo Printing array : $@ echo ---------------------------------- echo Number of arguments passed are $# # $# prints the number of argument echo ---------------------------------- echo Last execution status $? # 0 is success
Read Me :
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02