I have a file I created by rm -f collate.txt && touch collate.txt
.
Then the following script works
while true; do wc -l collate.txt | awk '{print $1}'; sleep 1; done
.
It prints something like this
0
431
851
1000
What I want to achieve is take these counts from awk
and subtract the present total lines number from the previous total lines number. Something like 431-0, 851-431, 1000-851.
I have tried doing it but it’s not working. I did something like
DIFF=0; while true; do wc -l collate.txt | awk ‘{print $1}’ | xargs -i $(({}-DIFF)) ; sleep 1; done
Can anyone help me out with this? Thanks