Skip to main content
added 470 characters in body
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

Using GNU sed, and assuming your file is small enough to fit in memory, you can do this:

$ sed -z 's/.*jum//' file 
ps over
the lazy
dog

The -z tells sed to treat its input as NUL-separated, meaning that it expects a NUL (\0) to signidfy the end of each line. Since your file will have no NUL characters, this has the effect of sed treating the entire file as a single line so we can do the whole thing in a single s/// operation.

Note that this will find the last jum in the file and delete everything before that. If there are other occurrences of jum earlier, those will be removed.

Using GNU sed, and assuming your file is small enough to fit in memory, you can do this:

$ sed -z 's/.*jum//' file 
ps over
the lazy
dog

Using GNU sed, and assuming your file is small enough to fit in memory, you can do this:

$ sed -z 's/.*jum//' file 
ps over
the lazy
dog

The -z tells sed to treat its input as NUL-separated, meaning that it expects a NUL (\0) to signidfy the end of each line. Since your file will have no NUL characters, this has the effect of sed treating the entire file as a single line so we can do the whole thing in a single s/// operation.

Note that this will find the last jum in the file and delete everything before that. If there are other occurrences of jum earlier, those will be removed.

Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

Using GNU sed, and assuming your file is small enough to fit in memory, you can do this:

$ sed -z 's/.*jum//' file 
ps over
the lazy
dog