User Tools

Site Tools


case

If you want to send us your comments, please do so. Thanks
More on comments


Bash scripting: case

Examples

On one line

  case $HOSTNAME in Host1) echo Hello1 ;; Host2) echo Hello2 ;; *) echo Default;; esac
  case `hostname` in Host1) echo Hello1 ;; Host2) echo Hello2 ;; *) echo Default;; esac

In a script

  case $HOSTNAME in
    Host1)
      echo Hello1
      ;;
    Host2)
      echo Hello2
      ;;
    Host3 | Host4)
      echo Hello3&4
      ;;
    Host5|Host6)
      echo Hello5&6
      ;;
    "Host 7"|"Host 8")
      echo Hello7&8
      ;;
    *)
      echo Default hostname
      ;;
  esac

Bugs

Comments before the ;; does not work. This

echo Hello # echoing Hello ;;

does not work. Do

echo Hello ;; # echoing Hello

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
case.txt · Last modified: 02-07-2021 01:13 by wim