有txt文件-:
file1-
abhinav,Age_10,11,12,13,14,15
deepak,Age_10,11,12,13,14,15
file2-:
Dixit,15
Skoda,15
外壳脚本-:
old_count=`grep 'abhinav' | awk 'BEGIN { FS = "," } ; { print $2 }' | awk 'BEGIN { FS = "_" } ; { print $2 }'`
new_count=`grep 'dixit' | awk 'BEGIN { FS = "," } ; { print $2 }'`
sum=`expr $old_count + $new_count`
但是当这个脚本被执行时,就会出现错误 expr: non-numeric argument iscoming 。虽然两个变量 $old_count $new_count 都是数字。