Skip to main content
2 of 2
added 236 characters in body
Shawn
  • 1.4k
  • 9
  • 9

Using aned one-liner:

printf "%s\n" '?^OPERATIONAL SYSTEMS TOMORROW:$?,$w' | ed -s arquivo

or with ex instead:

ex -sc '?^OPERATIONAL SYSTEMS TOMORROW:$?,$wq!' input.txt

these rewrite arquivo to save only everything from the last matching line to the end of the file.

Using a file-oriented tool like ed or ex instead of a stream-oriented one like sed or awk makes many non-trivial automated editing tasks much simpler because they can do things like search backwards from a cursor location.

Shawn
  • 1.4k
  • 9
  • 9