>Hi
>
>I have a log file, with entries that look like this:
>Fri Nov 19 11:09:04 1999 DNS 192.168.1.3:1519--->111.222.333.444:53
>www.omnicast.net
>
>(all on one line)
>
>I want to pull out the second IP address 111.222.333.444, do an nslookup
>on it to get the host/domain, and output everything tino a file like this:
>
>Fri Nov 19 11:09:04 1999 host.domain.com
>
>Is there any easy way to do this? Thanks..
>
>       Bryan
>
>

You can pick whatever part of almost anything using awk. With awk you 
define record separators (usually newlines by default) and field 
separators (usually tabs or spaces by default) and you can ask awk to 
print say field number 4 for you, and then within a shell script, do 
whatever you want with that (pipe it through nslookup for example). 
Record and field separators can be anything, including regexps...so 
it's really powerful.

If you pipe the standard input throught this simple line, it should 
print the 4th field of every record (default RS and FS):

awk '{ print $4 }'

in /usr/doc/gawk you can find plenty of documentation, including a 
book on awk by the FSF.

Hope this helps,

Fernan




Lic. Fernan Aguero                                        Tel: 
(54-11) 4752-0021
Instituto de Investigaciones Biotecnologicas              Fax: 
(54-11) 4752-9639
Universidad Nacional de General San Martin


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to