UPDATE I need to clarify that Jon8RFC-LT and DOMAIN are also just generic examples of dynamic content, like the IP address and MAC address; nmblookup retrieves and displays entirely dynamic content based on the ip address. If awk is used, I need to have a way to pull 4 dynamic values from the nmblookup: IP, hostname/asset name, domain name, MAC address. Sorry for the confusion, I updated the code to make it more clear.
I have been searching and using my Linux book for a couple of days and cannot find what I need for awk/gawk/grep/egrep/sed (I think I need one or more of those, elegantly). In a bash script, I'm running:
su_nmblookup=$(nmblookup -A $ipaddress)
which returns
WARNING: The "idmap backend" option is deprecated added interface eth0 ip=a07d::a07d:a07d:a07d:a07d%eth0 bcast=b57d::ffff:ffff:ffff:ffff%eth0 netmask=ffff:ffff:ffff:ffff:: added interface eth1 ip=b57d::b57d:b57d:b57d:b57d%eth1 bcast=a07d::ffff:ffff:ffff:ffff%eth1 netmask=ffff:ffff:ffff:ffff:: added interface eth0 ip=234.234.234.234 bcast=12.12.12.12 netmask=255.255.0.0 Socket opened. Looking up status of 123.123.123.123 JON8RFC-LT <00> - B <ACTIVE> DOMAIN <00> - <GROUP> B <ACTIVE> JON8RFC-LT <20> - B <ACTIVE> DOMAIN <1e> - <GROUP> B <ACTIVE> MAC Address = 4F-A2-4F-A2-4F-A2
The best I've managed, is to chop it down with this code:
display=${su_nmblookup/#*Looking/\Looking}
Looking up status of 123.123.123.123 JON8RFC-LT <00> - B <ACTIVE> DOMAIN <00> - <GROUP> B <ACTIVE> JON8RFC-LT <20> - B <ACTIVE> DOMAIN <1e> - <GROUP> B <ACTIVE> MAC Address = 4F-A2-4F-A2-4F-A2
However, what I'd like to know is how to return either of these cleaned up formats. I want to learn how the grep/awk/sed works with extracting data with these two examples, one with preserving the formatting, and one with just new lines. I had a hell of a time even getting the quoting/coding to work properly here because of the formatting and gt/lt symbols!
Looking up status of 123.123.123.123 JON8RFC-LT DOMAIN 4F-A2-4F-A2-4F-A2
OR, simply
JON8RFC-LT DOMAIN 123.123.123.123 4F-A2-4F-A2-4F-A2
Thank you for your help!