hostdig

Pass stdin into Unix host or dig command


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.?


Solution

  • Use xargs -l:

    tail -f access.log | xargs -l host