shell 默认参数

#!/bin/bash
v=${1:-'1.0.0'}
h=${2:-'test demo'}
echo ${v}
echo ${h}

输出:

[root@master ~]# bash test.sh 
1.0.0
test demo
[root@master ~]# bash test.sh  abc 123
abc
123
Copyright © ghostwritten 浙ICP备2020032454号 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-06-22 07:59:54

results matching ""

    No results matching ""