我想从文件中每两行打印和减去
toto 30
tata 20
toto 12
tata 6
toto 22
tata 8
输出 :
diff : 10
diff : 6
diff : 14
我找到一个脚本:
FILENAME=$1
while read line
do
if [ -n "$prevLine" ]
then
curLine=$line
echo $(($curLine - $prevLine))
fi
prevLine=($line)
done < $FILENAME
我想阅读 line+1 来制作 2 的范围