How to add text after last pattern match using ed

前端 未结 2 1524
执念已碎
执念已碎 2021-01-16 20:31

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         


        
2条回答
  •  隐瞒了意图╮
    2021-01-16 21:28

    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.

提交回复
热议问题