I have a file which contains
...
CNN
111
XXX
ABC
111
XXX
ABC
111
BBC
...
and I need to change the 111 to 999 but only as part of ABC\n111\nXXX
...
CNN
111
XXX
ABC
999
XXX
ABC
111
BBC
...
I have tried this, but it changes "111" everywhere.
perl -i -pe '/ABC\n111\nXXX/ if s/111/999/g' FILE
Note: We need to compare multiple lines as "111" might be in many other places. The file size is 227kb.