?? unit-conversion.sh
字號:
#!/bin/bash# unit-conversion.shconvert_units () # 通過參數(shù)取得需要轉(zhuǎn)換的單位. { cf=$(units "$1" "$2" | sed --silent -e '1p' | awk '{print $2}') # 除了真正需要轉(zhuǎn)換的部分保留下來外,其他的部分都去掉. echo "$cf"} Unit1=milesUnit2=meterscfactor=`convert_units $Unit1 $Unit2`quantity=3.73result=$(echo $quantity*$cfactor | bc)echo "There are $result $Unit2 in $quantity $Unit1."# 如果你傳遞了兩個不匹配的單位會發(fā)生什么? #+ 比如分別傳入"英畝"和"英里"? exit 0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -