This is how I am adding text before first pattern, I want to add after last pattern
FILE_NAME=\"folder/myfile.c++\" STR_TO_ADD=\"string tha
Go to last line of file and search pattern in backward direction.
FILE_NAME="folder/myfile.c++" STR_TO_ADD="string that i want to add" PATTERN="banana" ed $FILE_NAME 2>NULL 1>NULL<
$ last line of file. ?^$PATTERN search pattern in backward direction from current line.
$
?^$PATTERN