samedi 1 avril 2017

How to write if/else with boolean in Bash?

How can I write an if then statement to switch between these to variables as such:

if(switch){
  server_var_shortname=$server_shared_shortname
  server_var=$server_shared
  server_var_bare=$server_shared_bare
} else {
  server_var_shortname=$server_vps_shortname
  server_var=$server_vps
  server_var_bare=$server_vps_bare
}

I'm not familiar with bash syntax and basically just need an if/else statement on a Boolean. Also can I use true / false values as such? Also how do I do the else statement?

$switch=true;
if $switch
then
  server_var_shortname=$server_shared_shortname
  server_var=$server_shared
  server_var_bare=$server_shared_bare
fi

Aucun commentaire:

Enregistrer un commentaire