如何从url中提取ip地址

Ani*_*udh 0 shell awk grep

我有一个配置文件,其内容如下:

db.path=/home/kpmg/test/dbfiles/dbone.db
db.connection.timeout=500000
server.url=http://a.b.c.d:8033/plain/httpds?
output.file.path=/home/kpmg/test/dbfiles/
log.file.path=/home/kpmg/test/dbfiles/
log.level=DEBUG
Run Code Online (Sandbox Code Playgroud)

我需要从server.url行中提取ip地址.我通过阅读示例和文档尝试使用几个awk命令,但无法正确使用它.

Chr*_*our 6

awk打印IP的一种方法:

$ awk -F'[/:]' '/server[.]url/{print $4}' file
a.b.c.d
Run Code Online (Sandbox Code Playgroud)

或使用GNU grep:

$ grep -Po '(?<=server.url=http://)[^:]*' file
a.b.c.d
Run Code Online (Sandbox Code Playgroud)

或者只是grep为了IP:

$ egrep -o '([0-9]{1,3}[.]){3}[0-9]{1,3}' file
Run Code Online (Sandbox Code Playgroud)