Increment number using AWK

Viewed 306

I have a file which contains the following:

export TM_FUNCTION=SUM08619 ;export TM_PARAM_SEQNO=2 ;export PSEUDO_USER=HIHI; . /projects/MSS/LEE1MP/shells/sumh8701.sh  001 DATE:W:0:C:D:1:11:1:N:: DATE:W:0:C:D:1:11:N:1:W: IT ++ ++ 000052233714 DATE:W:0:C:D:1:11:N:N:: 100000 N FMPOST A / &

If i run the following value 100000 is returned:

awk -F' ' '{ print $17 }' filename

I would like to increment $17 using a script by 1 each time i run what is the best way?

1 Answers

You can use

awk '{$17=$17+1}1' filename > tmp && mv tmp filename

Calling this each time will increment Field 17 by one.

If you have a GNU awk you may use

awk -i inplace '{$17=$17+1}1' filename
Related