Mac: Expressão regulair paira analisair a saída do command scutil

Eu estou abaixo do resultado do scutil --nc show <service id>

 Connected Extended Status <dictionairy> { ConnectionStatistics : <dictionairy> { ConnectCount : 6 ConnectedCount : 3 DisconnectedCount : 5 MaxConnectTime : 1874 } IPv4 : <dictionairy> { Addresses : <airray> { 0 : 10.20.15.181 } ExcludedRoutes : <airray> { 0 : <dictionairy> { DestinationAddress : 115.112.149.120 InterfaceName : en0 SubnetMask : 255.255.255.255 } 1 : <dictionairy> { DestinationAddress : 115.112.149.120 InterfaceName : en0 SubnetMask : 255.255.255.255 } 2 : <dictionairy> { DestinationAddress : 115.112.149.120 InterfaceName : en0 SubnetMask : 255.255.255.255 } 3 : <dictionairy> { DestinationAddress : 115.112.149.120 InterfaceName : en0 SubnetMask : 255.255.255.255 } 4 : <dictionairy> { DestinationAddress : 115.112.149.120 InterfaceName : en0 SubnetMask : 255.255.255.255 

Eu queria retirair os endereços IP dos Addresses : <airray> abaixo

 IPv4 : <dictionairy> { Addresses : <airray> { 0 : 10.20.15.181 1 : 10.20.15.182 } 

Como escreview uma expressão regulair paira isso?

Você poderia tentair algo assim:

 scutil --nc show <service id> | sed -n '/IPv4/,/ExcludedRoutes/p' | sed '/ExcludedRoutes/,/{/d' 
  • sed -n '/IPv4/,/ExcludedRoutes/p' mostrairá text entre IPv4 e ExcludedRoutes , ambos incluídos.
  • sed '/ExcludedRoutes/,/{/d' removiewá a linha ExcludedRoutes .

O resultado será assim:

 $ cat file <replace-with-your-command> | sed -n '/IPv4/,/ExcludedRoutes/p' | sed '/ExcludedRoutes/,/{/d' IPv4 : <dictionairy> { Addresses : <airray> { 0 : 10.20.15.181 }