Changing only IP from Config file

I am trying to change IP from one of the config file, able to change IP or replace IP but how to preserve its port along with IP.

file having below line, where I only want to put another IP.

Config Server=**x.x.x.x**:689

(preceding text of first “=” of it & “=1.2.3.4:” & following text of last “:” of it) of “Config Server=x.x.x.x:689”

2 Likes

thx :slight_smile: please how to pass it in below line

appendfile {concatenation “%0d%0a” of ( if (it starts with “Config Server=”) then (“Config Server=” & (parameter “IP”)) else it as string) of lines of file (parameter “config_file_name”)}

OK got it !

appendfile {concatenation “%0d%0a” of ( if (it starts with “Config Server=”) then (“Config Server=” & (parameter “IP”) & “:” & following text of last “:” of it) else it as string) of lines of file (parameter “config_file_name”)}

1 Like

Another method to replace a known string

Q: concatenation "1.2.3.4" of substrings separated by "x.x.x.x" of "Config Server=x.x.x.x:689"
A: Config Server=1.2.3.4:689
1 Like