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

Replace end 2 lines of file

Status
Not open for further replies.

chomps303

MIS
Sep 30, 2003
83
US
I have to replace the last line of my .profile file with new line and what was origionaly there.

example:
Here is what I have now:

PATH=$PATH:$HOME/bin:/usr3/:/usr/blast:/usr/wp51/wpbin #set command search path
exec /usr/local/bin/mmm
(EOF):


Here is what I want to end with:

PATH=$PATH:$HOME/bin:/usr3/:/usr/blast:/usr/wp51/wpbin #set command search path
PRINTER=39;export PRINTER <<< This was added
exec /usr/local/bin/mmm
(EOF):


Thanks

Brandt



 
Perhaps use sed?

sed '$ iPRINTER=39;export PRINTER' .profile > .profile.new
 
Exactly what I was looking for!!!!

How does it know to use the next to last line?

Thanks so much

Brandt
 
How does it know to use the next to last line?
Because on the last line (address=$) we do an insert before (i\ command).

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top