ex-08-01_varsub.sh
来自「Berkely的学生写的」· Shell 代码 · 共 17 行
SH
17 行
#!/bin/sh# Chapter 08 - Section Variable Substitution# This script demonstrates the substitution operatorsecho "Test 01 - Substituting a Default Value"PS1=${HOST:-localhost}"$ " ; export PS1 ;echo $PS1echo "Test 02 - Assigning a Default Value"PS1=${HOST:=`uname -n`}"$ " ; export PS1 HOST ;echo $PS1echo "Test 03 - Aborting Due to Variable Errors": ${HOME:?"Your home directory is undefined."}echo "Test 04 - Substitution when a Variable is Set"echo ${DEBUG:+"Debug is active."}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?