Glam Prestige Journal

Bright entertainment trends with youth appeal.

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
eof

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

1

2 Answers

cp textfile /tmp/textfile
awk '{if ($1 == "Rev") printf("%s %d\n", $1, $2 + 1); else print $0;}' /tmp/textfile > textfile

awk:

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy