unit-conversion.sh

来自「Shall高级编程」· Shell 代码 · 共 25 行

SH
25
字号
#!/bin/bash# unit-conversion.shconvert_units ()  # Takes as arguments the units to convert.{  cf=$(units "$1" "$2" | sed --silent -e '1p' | awk '{print $2}')  # Strip off everything except the actual conversion factor.  echo "$cf"}  Unit1=milesUnit2=meterscfactor=`convert_units $Unit1 $Unit2`quantity=3.73result=$(echo $quantity*$cfactor | bc)echo "There are $result $Unit2 in $quantity $Unit1."#  What happens if you pass incompatible units,#+ such as "acres" and "miles" to the function?exit 0

⌨️ 快捷键说明

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