localhost=${host:-"localhost"}

host 变量未设定或者为空,host取"-"后面的值;否则host=$host

host=${host-"localhost"}

host 变量未设定,host取"-"后面的值;否则如果变量host为空或者有值host=$host

 

host=${host:-"localhost"}

一般前面会有一个read -p "请输入一个参数:" host

即:当提示你输入参数,但是你直接Enter,这时候host是为空的, localhost这个字符串作为它的值.否则就会使用你输入的字符串作为值

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2021-12-24
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-08-10
  • 2021-08-03
  • 2021-08-14
  • 2021-12-03
相关资源
相似解决方案