Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a text file as input. I need to filter that through some program, SED, AWK, whatever, where i need to increment a value in a particular line every time i run the script.

What's the best way of doing it?

Sample text:

File Type
Rev 100
data a
data b
file loc
comment line

only the "Rev 100" should change to "Rev 101"

share|improve this question
provide a sample – akira Oct 11 '10 at 8:42

2 Answers 2

up vote 1 down vote accepted
cp textfile /tmp/textfile
awk '{if ($1 == "Rev") printf("%s %d\n", $1, $2 + 1); else print $0;}' /tmp/textfile > textfile
share|improve this answer


/^Rev / {
  print "Rev " $2+1

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.