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

📄 read-novar.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# read-novar.shecho# -------------------------- #echo -n "Enter a value: "read varecho "\"var\" = "$var""# Everything as expected here.# -------------------------- #echo# ------------------------------------------------------------------- #echo -n "Enter another value: "read           #  No variable supplied for 'read', therefore...               #+ Input to 'read' assigned to default variable, $REPLY.var="$REPLY"echo "\"var\" = "$var""# This is equivalent to the first code block.# ------------------------------------------------------------------- #echoecho "========================="echo#  This example is similar to the "reply.sh" script.#  However, this one shows that $REPLY is available#+ even after a 'read' to a variable in the conventional way.# ================================================================= ##  In some instances, you might wish to discard the first value read.#  In such cases, simply ignore the $REPLY variable.{ # Code block.read            # Line 1, to be discarded.read line2      # Line 2, saved in variable.  } <$0echo "Line 2 of this script is:"echo "$line2"   #   # read-novar.shecho            #   #!/bin/bash  line discarded.# See also the soundcard-on.sh script.exit 0

⌨️ 快捷键说明

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