How to increase value of a text variable in a file
问题 file1.text contains below data. VARIABLE=00 RATE=14 PRICE=100 I need to increment value by 1 only for below whenever I want. VARIABLE=00 file name: file1.txt output should be incremented by 1 every time. output will be like below VARIABLE=01 in next run VARIABLE=02 and so on.... 回答1: Could you please try following, written and tested with shown samples in GNU awk . awk 'BEGIN{FS=OFS="="} /^VARIABLE/{$NF=sprintf("%02d",$NF+1)} 1' Input_file > temp && mv temp Input_file Explanation: Adding