[OT SED AWK BASH] How to trim out a line ending?
Note: if my [OT] posts about sed/awk/bash/perl/grep upset anyone, please send me a message. ---------------------------------------------- Ok, unfortunately nslookup spits out the desired info in 6 lines like such: Server: ns1.theplanet.com Address: 216.234.234.30 Non-authoritative answer: Name: apple.com Address: 17.254.3.183 [jw@garnet jw]$ In order to clean that up I need to remove the end-of-line/newline pair that /precedes/ each Address: line. I also need to remove the blank line, but I don't know how to match either blank lines or line endings/newlines. How do I match those? P.S. Anyone have a link for a reg-exps for newbies howto? Sooner or later I'll read one of the big books, but at the moment I'm thinking of something more along the lines of a cheat sheet for quick lookups. ---------------------------------------------------- Jonathan Wilson System Administrator Cedar Creek Software http://www.cedarcreeksoftware.com Central Texas IT http://www.centraltexasit.com
Today, Jonathan Wilson wrote...
Ok, unfortunately nslookup spits out the desired info in 6 lines like such:
Server: ns1.theplanet.com Address: 216.234.234.30
Non-authoritative answer: Name: apple.com Address: 17.254.3.183
[jw@garnet jw]$
you could try to use "host"... it's output is cleaner:
host slashdot.org slashdot.org has address 64.28.67.150 slashdot.org mail is handled (pri=10) by mail.upn.net slashdot.org mail is handled (pri=20) by mail2.upn.net
if the host has more tan one ip the output will have many "xxx.xxx has address 11.22.33.44" lines (try with www.us.kernel.org) so you could do for hosts in `cat hostnames`; do host $hosts | grep address | awk '{print $4}'; done > output.txt for example. Best whishes Adilson Ribeiro
participants (2)
-
Adilson Guilherme Vasconcelos Ribeiro
-
wilson@claborn.net