Link to home
Start Free TrialLog in
Avatar of ipconfig610
ipconfig610Flag for United States of America

asked on

Linux need help filtering with sed or awk or grep

I am trying to extract IP address information out of Asterisk in real-time.  The following command results with the following output.

/usr/sbin/asterisk -rx "sip show peers" > ToTextFile.txt

cat ToTextFile.txt
sip115_espjcs/sip115_espj  98.114.xxx.xxx     D   N      5060     Unmonitored Cached RT
sip114_espjcs/sip114_espj  98.114.xxx.xxx     D   N      5060     Unmonitored Cached RT
sip226_trfirstohiobank/si  96.11.xxx.xxx    D   N      5060     Unmonitored Cached RT
sip8211_trpmr/sip8211_trp  75.11.xxx.xxx    D   N      5060     Unmonitored Cached RT
sip119_ftiehr/sip119_ftie  173.81.xxx.xxx   D   N      5060     Unmonitored Cached RT

Open in new window


I would like the result of the output to only show me an IP address list.

The result away shows 27 characters before the IP address and the IP address is never more then 15 characters long.  the rest can be cut.  Any help in formatting would be great.

Thanks
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

/usr/sbin/asterisk -rx "sip show peers"  | awk '{print $2}'
Avatar of ipconfig610

ASKER

Wow perfect!  I have a few "(Unspecified)" that show up in the list.  Is there a way to filter these out?

75.144.xxx.xxx
75.144.xxx.xxx
(Unspecified)
75.144.xxx.xxx
75.144.xxx.xxx

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial