⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex6.sh

📁 一本完整的描述Unix Shell 编程的工具书的所有范例
💻 SH
字号:
#!/bin/bash#  Check some of the system's environmental variables.#  This is good preventative maintenance.#  If, for example, $USER, the name of the person at the console, is not set,#+ the machine will not recognize you.: ${HOSTNAME?} ${USER?} ${HOME?} ${MAIL?}  echo  echo "Name of the machine is $HOSTNAME."  echo "You are $USER."  echo "Your home directory is $HOME."  echo "Your mail INBOX is located in $MAIL."  echo  echo "If you are reading this message,"  echo "critical environmental variables have been set."  echo  echo# ------------------------------------------------------#  The ${variablename?} construction can also check#+ for variables set within the script.ThisVariable=Value-of-ThisVariable#  Note, by the way, that string variables may be set#+ to characters disallowed in their names.: ${ThisVariable?}echo "Value of ThisVariable is $ThisVariable".echoecho: ${ZZXy23AB?"ZZXy23AB has not been set."}#  If ZZXy23AB has not been set,#+ then the script terminates with an error message.# You can specify the error message.# : ${variablename?"ERROR MESSAGE"}# Same result with:    dummy_variable=${ZZXy23AB?}#                      dummy_variable=${ZZXy23AB?"ZXy23AB has not been set."}##                      echo ${ZZXy23AB?} >/dev/null#  Compare these methods of checking whether a variable has been set#+ with "set -u" . . .echo "You will not see this message, because script already terminated."HERE=0exit $HERE   # Will NOT exit here.# In fact, this script will return an exit status (echo $?) of 1.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -