Article 4SA60 Looking for a sed one-liner to do one of two things

Looking for a sed one-liner to do one of two things

by
oldpink
from LinuxQuestions.org on (#4SA60)
I'm trying to write up a sed one-liner (using pure sed and no pipes) to do two separate tasks:
1) Print out each line in a text file with its specific line number at the beginning of each line.

Change this:
Line one
Line two
Line three

Into this:
1 Line one
2 Line two
3 Line three

2) Find the last matching line number of text in a file.

Example:
Jones George
Doakes Joe
Jones George
PRINT "3" to indicate the last match.

Before I get asked why I don't just use awk or nl to do this, or why not pipe several commands using sed together to do it, my situation calls for pure sed as a one-liner only, plus I'm trying to learn more about the more advanced features of sed while I'm at it.
I'd be grateful for whatever anyone can tell me.latest?d=yIl2AUoC8zA latest?i=LpcEQKL3Mxs:f0CSjDujBgI:F7zBnMy latest?i=LpcEQKL3Mxs:f0CSjDujBgI:V_sGLiP latest?d=qj6IDK7rITs latest?i=LpcEQKL3Mxs:f0CSjDujBgI:gIN9vFwLpcEQKL3Mxs
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments