Inserting Multiple Lines (with newline) using sed or awk
So far, I've only done basic substitution with sed, so dont know if this is possible.
I need to replace part of a line in a file with multiple lines, however need to separate each line with a newline is this possible? Example, need to remove line 2 </head> <h1>My Blog</h1> and insert line similar to below: --snip </head> <body background="gifs/blue.gif"> <table class="table-head"> <tr> <td><img src="jpgs/image_a.jpg" border="0"></td> <td valign="middle" align="center" style="font-size: 40px; color:red">My Blog</td> <td><img src="jpgs/image_b.jpg" align="right" border="0"></td> </tr> If the multiple lines were part of a text file, would inserting a text file automatically include newline characters? Thanks in advance to anyone who can help? |
Put the lines you want to add into another file, and then feed that into your sed command using the r filename syntax.
Here's an example: Code:
telemachus ~/practice $ cat practice |
All times are GMT -5. The time now is 11:38 AM. |