Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sed replace dns strings in file

29 views
Skip to first unread message

Matthew Kruer

unread,
Nov 8, 2012, 8:04:11 PM11/8/12
to
This should be simple. I am looking to replace dns names in multiple files the search criteria are (a-z A-Z 0-9 . -) those should be all the legal charters.

SERVERNAME="someserver"
SEARCHSTRING="[a-zA-Z0-9\.\-]*"

sed -i "s|dbserver=$SEARCHSTRING|dbserver=$SERVERNAME|gI"
sed -i "s|EPG_FTP_HOST=$SEARCHSTRING|EPG_FTP_HOST=$SERVERNAME|gI"
sed -i "s|jdbc:oracle:thin:@$SEARCHSTRING:1521:oracle|jdbc:oracle:thin:@$SERVERNAME:1521:oracle|gI"

The issue that I am having is that when I comes to periods and hyphens the search string ends.

I should be replace any of the following names with a new name
system-1.someaddress.com
system-1
system
etc...

thanks in advance

Matthew Kruer

unread,
Nov 8, 2012, 8:11:59 PM11/8/12
to
Got it

SEARCHSTRING="[a-zA-Z0-9.-]*"

Barry Margolin

unread,
Nov 8, 2012, 9:53:42 PM11/8/12
to
In article <c48b6ca6-75de-4532...@googlegroups.com>,
Put the hyphen first, so it's not between two characters and can't be
interpreted as a range delimiter.

Also, you don't need to escape the period inside a character class.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
0 new messages