Pass stdin into Unix host or dig command

tomasz picture tomasz · Aug 7, 2009 · Viewed 8.5k times · Source

Let's say I have a list of IPs coming into a log that I'm tailing:

1.1.1.1
1.1.1.2
1.1.1.3 

I'd like to easily resolve them to host names. I'd like to be able to

tail -f access.log | host - 

Which fails as host doesn't understand input from stdin in this way. What's the easiest way to do with without having to write a static file or fallback to perl/python/etc.?

Answer

Sinan Taifour picture Sinan Taifour · Aug 7, 2009

Use xargs -l:

tail -f access.log | xargs -l host