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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding new lines at lines 95 of 233 2

Status
Not open for further replies.

fidge

Technical User
Jun 11, 2003
20
0
0
GB
Hi,

I'm trying to add 17 new lines after a certain string is found. The string is located on line 94 of a 233 line file.

I've found the following, which adds the new lines correctly, but does not write lines 96-233 to the output file:

awk '1;$1=="name=mark"{exit}END{print "name2=scott\n name3=harry\n name4=dick etc...."}' m.m > m.new

Can someone let me know how I can make the cmd continue and write out the other 140 lines after i've inserted the new lines?

Thanks in advance for any help
fidge
 
awk '1;$1=="name=mark"{print "name2=scott\n name3=harry\n name4=dick etc...."}' m.m > m.new



Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
awk '{print} $1 == "name=mark" {print "name2=scott\n...."}' m.m > m.new

Annihilannic.
 
thanks PHV and Annihilannic, both solutions worked.
I see where I went wrong now.
 
sorry to intrude on this one, it's just strange to see someone I know posting. Probably because I don't come in the awk forum too often.

How's it going Annihiannic?

Speak soon,

Richard
 
Hiya Rich :), good to see you found this excellent site... or did I point you in its direction...?

'later,

Annihilannic.
 
Been using it since 2000, normally to be found in the php or css forums though. Definitely an excellent site though.

Maybe see you round Béziers,

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top