[code]#!/bin/bash
MINPARAMS=10
echo
echo "the name of this script is \"$0\"."
echo "the name of this script is \"basename $0\"."
echo "============================================"
echo
if[-n "$1"];then
echo "parameter #1 is $1"
fi
if[-n "$2"];then
echo "parameter #2 is $2"
fi
echo "============================================"
echo "all the parameter are $*"
echo "the number of parameter is $#"
echo
[/code]运行结果:
the name of this script is "./parameter.sh".
the name of this script is "basename ./parameter.sh".
============================================
./parameter.sh: line 9: syntax error near unexpected token `then'
./parameter.sh: line 9: `if[-n "$1"];then'
yanyongkg 于 2012-03-17 13:28:50发表:
if [ 之间也要空格
于 2012-03-17 13:28:00发表:
if [ 之间也得空格
相思爱文 于 2012-03-17 11:58:25发表:
[ 和 ] 两边要留有空格才行
if [ -n "$1" ] ;then