Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using sed to sub a new line

Status
Not open for further replies.

mbrohm

Programmer
Sep 18, 2002
5
US
I am trying to change a file to add information at certain points, but I also need to a new line like add:

test = true
metadata = false

so i did a sed 's/end/^M test = true ^M metadata = false/' tmp > tmp2

but in tmp2 i see end^M test = true^M metadata = false.

I have also tried \n instead of ^M but i get n in the file and I have tried \\n which gives me \n in the file. Any ideas of what I am doing wrong??

Thanks
 
append lines after matching pattern:
/pattern/ahkjhkjhkjhkjhkjhkh
opipoppipoippipoip
lkjlkjlkjljlkjl
<here-is-an-empty-line>

insert lines before matching pattern:
/pattern/ihkjhkjhkjhkjhkjhkh
opipoppipoippipoip
lkjlkjlkjljlkjl
<here-is-an-empty-line>

------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top