Reputation: 25
I've gone through many awk questions here on SO, but still can not create one for my purpose.
I have a file like such:
Project Name
Version 1.0
Revision 0059
How do I increment 0059 to 0060 while keeping the rest the same?
Upvotes: 1
Views: 721
Reputation: 31548
Try this
sed -rne '/^Revision/s/Revision ([0-9]+)/\1/gp' temp.txt | awk '{printf("%04d\n",$0+1)}'
Upvotes: 0
Reputation: 16974
One way:
$ awk '$1=="Revision"{$2=sprintf("%04d",$2+1);}1' file
Project Name
Version 1.0
Revision 0060
Upvotes: 1