我有脚本文件。
for file in *.TXT
do
amount=$(less $file | grep BPR | awk -F'CACH' '{c=$1;sub(/[^0-9]*/,"",c);total+=c/100}END{printf "%.2f", total}')
totalAmount=$(expr $totalAmount+$amount)
done
现在我的脚本看起来像这样
for file in *.TXT
do
amount=$(less $file | grep BPR | awk -F'CACH' '{c=$1;sub(/[^0-9]*/,"",c);total+=c/100}END{printf "%.2f", total}')
echo "$totalAmount += $amount" | bc -l
done
echo $totalAmount
但是当我运行它时,它会在$totalAmout+=$amount处引发错误。
我需要将总金额存储在变量中,如 totalAmount。
请帮我