In the above ruby example he's just shelling out to the unix `ping` command. That's what the backticks allow you to do. You could probably do the same thing in java with different syntax.
With bash all you have to do is redirect the output to a file. I'll let you figure out the loop part yourself but here's how you could parse out the IP address of the ping command.
Code:
ping -q -c1 google.com | awk '{ print $3 }' | head -n1
And if you want to write the output to a file:
Code:
ping -q -c1 google.com | awk '{ print $3 }' | head -n1 > ip_list
If I were you I'd do something like:
1. Have a file with a list of host names on each line
2. Write a bash script that takes that file as input
3. Loop through the file, splitting on a new line
4. Append the IP address next to each host in each loop iteration as a string
5. After the loop is done, write the new file
If modularity isn't of great important, just store #1 inside of the bash script as an array.