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

📄 resistor-inventory.sh

📁 一本完整的描述Unix Shell 编程的工具书的所有范例
💻 SH
字号:
#!/bin/bash# resistor-inventory.sh# Simple database application using indirect variable referencing.# ============================================================== ## DataB1723_value=470                                   # OhmsB1723_powerdissip=.25                             # WattsB1723_colorcode="yellow-violet-brown"             # Color bandsB1723_loc=173                                     # Where they areB1723_inventory=78                                # How manyB1724_value=1000B1724_powerdissip=.25B1724_colorcode="brown-black-red"B1724_loc=24NB1724_inventory=243B1725_value=10000B1725_powerdissip=.25B1725_colorcode="brown-black-orange"B1725_loc=24NB1725_inventory=89# ============================================================== #echoPS3='Enter catalog number: 'echoselect catalog_number in "B1723" "B1724" "B1725"do  Inv=${catalog_number}_inventory  Val=${catalog_number}_value  Pdissip=${catalog_number}_powerdissip  Loc=${catalog_number}_loc  Ccode=${catalog_number}_colorcode  echo  echo "Catalog number $catalog_number:"  echo "There are ${!Inv} of [${!Val} ohm / ${!Pdissip} watt] resistors in stock."  echo "These are located in bin # ${!Loc}."  echo "Their color code is \"${!Ccode}\"."  breakdoneecho; echo# Exercises:# ---------# 1) Rewrite this script to read its data from an external file.# 2) Rewrite this script to use arrays,#+   rather than indirect variable referencing.#    Which method is more straightforward and intuitive?# Notes:# -----#  Shell scripts are inappropriate for anything except the most simple#+ database applications, and even then it involves workarounds and kludges.#  Much better is to use a language with native support for data structures,#+ such as C++ or Java (or even Perl).exit 0

⌨️ 快捷键说明

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