[root@station shell]# cat 6.sh
#!/bin/bash
MIN_PARAMETERS=10
echo
echo "The name of this script is \"`basename $0`\"."
echo
if [ -n "$1" ]
then
echo "parameter #1 is $1"
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}" ]
then
echo "parameter #10 is ${10}"
fi
echo "______________________________________________________"
echo "All the command-line parameters are: "$*""
if [ $# -lt "$MIN_PARAMETERS" ]
then
echo
echo "this script need at least $MIN_PARAMETERS command line args"
fi
echo
exit 0
[root@station shell]# ./6.sh 1 2 3 4 5 6 7 8 9 10
The name of this script is "6.sh".
parameter #1 is 1
parameter #2 is 2
parameter #3 is 3
parameter #4 is 4
parameter #5 is 5
parameter #6 is 6
parameter #7 is 7
parameter #8 is 8
parameter #9 is 9
parameter #10 is 10
______________________________________________________
All the command-line parameters are: 1 2 3 4 5 6 7 8 9 10
[root@station shell]# ./6.sh
The name of this script is "6.sh".
______________________________________________________
All the command-line parameters are:
this script need at least 10 command line args