(no subject)

Date: 2009-05-15 08:57 pm (UTC)
lovingboth: (0)
From: [personal profile] lovingboth
Once I'd remembered that you don't stick $ in front of AWK variables, and that it'd be better to have them before the sentinel string...

awk '/END SENTINEL/ {print "This ["FNR"] is my new line";print;next}1' test-file


.. FNR = the line number, effectively.

So you get

forty-odd lines of blah
This [42] is my new line
END SENTINEL
more blah


Then all you have to do is remember you have to write it to a temporary file and move over the original rather than writing to the original. (A good way to delete your original!)
(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

lovingboth: (Default)
Ian

July 2025

S M T W T F S
  12345
6 789101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Active Entries

Style Credit

Expand Cut Tags

No cut tags