I've below output from scutil --nc show <service id>
Connected
Extended Status <dictionary> {
ConnectionStatistics : <dictionary> {
ConnectCount : 6
ConnectedCount : 3
DisconnectedCount : 5
MaxConnectTime : 1874
}
IPv4 : <dictionary> {
Addresses : <array> {
0 : 10.20.15.181
}
ExcludedRoutes : <array> {
0 : <dictionary> {
DestinationAddress : 115.112.149.120
InterfaceName : en0
SubnetMask : 255.255.255.255
}
1 : <dictionary> {
DestinationAddress : 115.112.149.120
InterfaceName : en0
SubnetMask : 255.255.255.255
}
2 : <dictionary> {
DestinationAddress : 115.112.149.120
InterfaceName : en0
SubnetMask : 255.255.255.255
}
3 : <dictionary> {
DestinationAddress : 115.112.149.120
InterfaceName : en0
SubnetMask : 255.255.255.255
}
4 : <dictionary> {
DestinationAddress : 115.112.149.120
InterfaceName : en0
SubnetMask : 255.255.255.255
I wanted to take out ip addresses from Addresses : <array>
from below
IPv4 : <dictionary> {
Addresses : <array> {
0 : 10.20.15.181
1 : 10.20.15.182
}
How to write regular expression for it?
Best Answer
You could try something like this:
sed -n '/IPv4/,/ExcludedRoutes/p'
will show text betweenIPv4
andExcludedRoutes
, both included.sed '/ExcludedRoutes/,/{/d'
will remove theExcludedRoutes
line.The result will be like this: