Shell-script: variable default vaule

  • english
  • spanish

It’s possible to assign a default value to a variable in case it isn’t already defined. The syntax is:

FOO=${FOO:=bar}

Example:

$ FOO=${FOO:=bar} $ echo $FOO bar $ BAR=test $ BAR=${BAR:=foo} $ echo $BAR test
Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Artículos relacionados (o no):

  • Pues no hay. :-(

0 Responses to “Shell-script: variable default vaule”


  1. No Comments

Leave a Reply




Creative Commons Attribution-NonCommercial 2.5 Spain
Creative Commons Attribution-NonCommercial 2.5 Spain