Linux program - 11.shell script (bash) - (6) Process Control Case

xiaoxiao2021-03-06  54

Case Word IN [Pattern [Pattern] ...) list ;;] ESAC Case / ESAC standard usage is as follows: Case $ arg in pattern | sample # arg in pattern or sample ;; pattern1) # arg In Pattern1 ;; *) #default ;; esac arg is the parameters you are introduced. If the Arg content is in line with the Pattern project, then the following code is executed, and the segment code is in two sequelions; "" Do the end. It can be noted that "Case" and "ESAC" are symmetrical. If you can't remember, "Case" is reversed. -------------------------------------------------- ------------------------------ Example: Paranoia #! / Bin / sh copy $ 1 in start | begin) echo "Start Something ";; STOP | END) Echo" stop Something ";; * Echo" ignorant ";; ESAC execution [Foxman @ foxman bash] # chmod 755 paraanoia [foxman @ foxman bash] # ./paranoia ignorant [foxman @ foxman Bash] # ./paranoia start start situation [foxman @ foxman bash] # ./paranoia begin start thing [foxman @ foxman bash] # ./paranoia stop stop Something [foxman @ foxman bash] # ./paranoia end stop something - -------------------------------------------------- ---------------------------- Example 2: INETPANEL Many Daemon will attach a managed shell script, attached like bind NDC, Apache is attached to apachectl. These management programs are written in Shell Script, and the following shows a shell script for INETD.

转载请注明原文地址:https://www.9cbs.com/read-117571.html

New Post(0)