Set Default Value on Shell
Jun222011
作者:u2 发布:2011-06-22 18:00 分类:shell Set Default Value on Shell已关闭评论
#!/bin/sh
# v_test.sh
# by 2hei.net 06/22/2011
#
#get param from command line
fisr_param=$1
second_param=$2
#set default value when null
fisr_param=${fisr_param:=”First”}
second_param=${second_param:=”Second”}
#print values
printf “fisr_param:\t”$fisr_param”\n”
printf “second_param:\t”$second_param”\n”
Run script…
#no params
[localhost]$sh v_test.sh
fisr_param: First
second_param: Second
#add params
[localhost]$sh v_test.sh hello baby
fisr_param: hello
second_param: baby
本文固定链接: https://www.2hei.net/2011/06/22/set_default_value_on_shell/ | 2hei.net
最活跃的读者