SED: Prefixing each line with certain string

Prefixing each line with certain string

$ sed -e 's/.*/ralph said: &/' origmsg.txt

Output of the above command

ralph said: Hiya Jim,
ralph said:
ralph said: I sure like this sed stuff!
ralph said:

In this example, we use the '&' character in the replacement string, which tells sed to insert the entire matched regular expression. So, whatever was matched by '.*' (the largest group of zero or more characters on the line, or the entire line) can be inserted anywhere in the replacement string, even multiple times. This is great, but sed is even more powerful.

For this ans much more examples of sed, please visit the source.
source: http://www.gentoo.org/doc/en/articles/l-sed2.xml

No comments: