示例
vim shell-args-test.sh
#!/bin/bash
# if no args specified, show usage
if [ $# -le 0 ]; then
echo '请指定参数'
exit 1
fi
echo $0
echo $1
输出
root@titvax:~/shell
$ sh ./shell-args-test.sh
请指定参数
root@titvax:~/shell
$ sh shell-args-test.sh hello
shell-args-test.sh
hello