I'm not sure if I got you correctly, but the following awk
script should work:
awk '{if(NR>1){print _n-$4};_n=$4}' your.file
Output:
23
24
21
21
22
25
18
21
43
21
You don't need the other programs in the pipe. Just:
awk '/\/dev\/vda/ {if(c++>0){print _n-$4};_n=$4}' src/checkout-plugin/a.txt
will be enough. The regex on start of the awk
scripts tells awk to apply the following block only to lines which match the pattern. A side effect is that NR
can't be used anymore to detect the "second line" in which the calculation starts. I introduced a custome counter c
for that purpose.
Also note that awk
will remove the M
on it's own, because the column has been used in a numeric calculation.