#! /Bin/bash
# Call this script with at least 10 parameters, for example
#./Scriptname 1 2 3 4 5 6 7 8 9 10
Minparams = 10
Echo
Echo "the name of this script is \" $0 \"."
Echo "the name of this script is \" 'basename $0 '\"."
Echo
If [-n "$1"]#-N test string be quoted is not null.
Then
Echo "parameter #1 is $1" # Need quotes to escape #
Fi
If [-n "$2"]
Then
Echo "parameter #2 is $2"
Fi
If [-n "$3"]
Then
Echo "parameter #3 is $3"
Fi
If [-n "$4"]
Then
Echo "parameter #4 is $4"
Fi
If [-n "$5"]
Then
Echo "parameter #5 is $5"
Fi
If [-n "$6"]
Then
Echo "parameter #6 is $6"
Fi
If [-n "$7"]
Then
Echo "parameter #7 is $7"
Fi
If [-n "$8"]
Then
Echo "parameter #8 is $8"
Fi
If [-n "$9"]
Then
Echo "parameter #9 is $9"
Fi
If [-n "$ {10}"]#
Parameters> $9 must be enclosed in {brackets}.
Then
Echo "parameter #10 is ${10 }"
Fi
Echo "-------------------------"
Echo "all the command-line parameters are:" $ *""
If [$ #-lt "$ minparams"]
Then
Echo
Echo "this script needs at least $ minparams command-line arguments! "
Fi
Echo
ARGs =$ ## Number of argS passed.
Lastarg =$ {! ARGs}
Echo "lastarg = $ lastarg"
Echo "lastarg =$ {! #}"
Exit 0
Note that$ #: Number of command-line arguments; $ *: All of the positional parameters and
Must be quoted "".