I am currently writing a shell (korn) script that automates a number of different tasks. One task in particular is giving me a little bit of trouble. I am trying to insert a text string at the beginning of each line in a text file using sed. Unfortunately, sed deletes the line when the insert is made, thus removing any existing text on each line. Does anyone know how to insert or (pre-pend) a text string to the beginning of each line in a file, while not affecting the text that’s already there?
Example:
-Before-
Smith, John
White, Bob
Jones, Frank
-After-
<option>Smith, John
<option>White, Bob
<option>Jones, Frank
As shown in the example, I want to insert the text string “<option>” before each existing line(s) that contain text, without removing the existing text.
Example:
-Before-
Smith, John
White, Bob
Jones, Frank
-After-
<option>Smith, John
<option>White, Bob
<option>Jones, Frank
As shown in the example, I want to insert the text string “<option>” before each existing line(s) that contain text, without removing the existing text.