Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get daily a text file with ip:port, one per line, example:

I would like to parse the first ip and port in two different variables, then write them into another file, wait exceution of a program that use these variables, loop this cycle to pass all the ip:port to the file and execute program.

How can I do that?

thank you

share|improve this question
up vote 0 down vote accepted

while read line junk
  ./nuke $addr $port
  case retval in
    0) echo "$addr $port nuked" >> nuke.log ;;
    *) echo "$addr $port avoid nuke" >> nuke.log ;;

done < /some/file/with/ipports
share|improve this answer
Solved:… , going anyway to check your solution to learn – MuZo Jul 11 '12 at 8:56
rewrite solution to meet all your conditions :) – Kondybas Jul 11 '12 at 9:06
thank you very much :) – MuZo Jul 11 '12 at 9:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.