处理用户输入_特殊参数变量_参数统计(1)
#!/bin/bash
# $#:含有脚本运行时携带的命令行参数的个数。
# counting command-line parameter
if [ $# -eq 1 ]
then
fragment="parameter was"
else
fragment="parameter were"
fi
echo $# $fragment supplied.
# ./countparameter1.sh
# ./countparameter1.sh hello
# ./countparameter1.sh hello world
# ./countparameter1.sh "hello world"
./countparameter1.sh
./countparameter1.sh hello
./countparameter1.sh hello world
./countparameter1.sh “hello world”