I'm trying to locate a block of text in a file, remove it and then replace with a new block.
I can find the first line number that the text starts on using grep -n. I then need to locate the ending line by searching for the string "}" that follows the line I found. Here's the steps I need to follow:
- Get line# of string "A" in file
- Get line# of string "B" based on starting line found in #1. (there are multiple occurences of this string, so I need to locate this string that not from the beginning of the file, but from the starting point that I found string A)
- Remove block of lines from #1 to #2 and replace with a new set of lines.
I know this is kinda complex, and will probably need an awk input file. I know awk, but not THAT well....
Thanks all!
Lloyd