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

sed replace

Status
Not open for further replies.

ksbrace

Programmer
May 13, 2000
501
US
Hello,
I'm attempting to do some find/replace in a bunch of files.

var loc = "
I want to replace the 8480

Code:
$SED 's/^.*http:\/\/'${SERVER_NAME}'.sunyconnect.suny.edu:.*\/F.*/    var loc = "http:\/\/'${SERVER_NAME}'.sunyconnect.suny.edu:'${HTTPD_PORT}'\/F;"'/ $INDEX > $INDEX_TEMP

Thanks in advance for any help.
 
That sed looks a bit confusing. Why not do something like this:

Code:
SERVERNAME="delaware"
HTTPD_PORT="2040"   # or whatever port you want to use
OLD_HTTPD="8480"
URL="[URL unfurl="true"]http://${SERVERNAME}.sunyconnect.suny.edu:8480"[/URL]
URL=`echo $URL | sed "s/$OLD_HTTPD/$HTTPD_PORT/g"`

echo $URL
[URL unfurl="true"]http://delaware.sunyconnect.suny.edu:2040[/URL]

The end result is that URL now has the new port assignment. While its not all wrapped up on one command, it is easier to read and see what is going on.

Add a little color to your PUTTY terminal: faq52-6627
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top