;; *) (Web server certificate) { body } ;; esac An
;; *) { body } ;; esac An example of the case command follows. This fragment of code sets the TYPE and RCFILE variables based on the user s default shell as reported in the seventh (colon-separated) field of the /etc/passwd file: Shell=`grep “^$USER:” /etc/passwd | awk -F: { print $7 } ` case “$Shell” in /bin/sh) TYPE=Bourne RCFILE=”.profile” ;; /bin/csh) TYPE=C RCFILE=”.cshrc” ;; /bin/bash) TYPE=Bourne RCFILE=”.bashrc” ;; /bin/tcsh) TYPE=C RCFILE=”.tcshrc” ;; *) TYPE=other RCFILE=”unknown” ;; esac The asterisk (*) is used as a catchall. If none of the other entries are matched on the way down the loop, the asterisk is matched and the value is set to unknown. The while . . . do and until . . . do loops Two other possible looping constructs are the while . . . do loop and the until . . . do loop. The structure of each is presented here: while condition until condition do do { body } { body } done done In a while loop, the condition is usually a test statement, but it can also be used to read input until an End-of-File (
In case you need quality webspace to host and run your web applications, try our personal web hosting services.