如何计算以下数据?
Input:
2 Printers
2 x 2 Cartridges
2 Router
1 Cartridge
输出:
Total Number of Printers: 2
Total Number of Cartridges: 5
Total Number of Router: 2
请注意,墨盒已成倍增加(2 x 2) + 1 = 5
。我尝试了以下操作,但不确定当我有(2 x 2)
场景类型时如何获取号码:
awk -F " " '{print $1}' Cartridges.txt >> Cartridges_count.txt
CartridgesCount=`( echo 0 ; sed 's/$/ +/' Cartridges_count.txt; echo p ) | dc`
echo "Total Number of Cartridges: $CartridgesCount"
请指教。