You can use the following syntax:
Code:
$ ./s
do u need this server[dingdong.xxx.com]:
server is: dingdong.xxx.com
$ ./s
do u need this server[dingdong.xxx.com]: another
server is: another
$ cat s
#! /bin/bash
read -p "do u need this server[dingdong.xxx.com]: " server
printf "server is: ${server:=dingdong.xxx.com}\n"
For more info check the man pages of your shell,
for example:
Code:
man bash|less -p:=
Code:
${parameter:=word} Assign Default Values. If parameter is unset or
null, the expansion of word is assigned to parame‐
ter. In all cases, the final value of parameter is
substituted. Only variables, not positional param‐
eters or special parameters, can be assigned in
this way.
|