我正在編寫一個腳本,它從文件中提取兩個值,然後減去它們。但我無法執行減法,因爲它引發錯誤。無法在shell腳本中減去兩個變量
res1= awk 'FNR == '${num1}' {print $1}' /home/shell/test.txt
res2= awk 'FNR == '${num2}' {print $1}' /home/shell/test.txt
res= $((res2 - res1))
echo $res
我也試過expr = `expr $res2 -$res1`
但它沒有工作。請幫助我以獲得理想的結果。
可能重複[在Bash中減去2個變量](http://stackoverflow.com/questions/8385627/subtract-2-variables-in-bash) – arved