Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

While trying melodyping, I noticed that

ping <host> |awk '{print $1}'

takes about 30 seconds until the first line is actually displayed. Even though w/o piping to awk each ping is returned in about 35 msec.

What causes that delay?

share|improve this question
    
Works fine for me. What do you get after 30 seconds? –  Eran Ben-Natan Apr 18 '12 at 11:33
    
@EranBen-Natan After those 30s I get a bulk of expected output, i. e. lines from ping with times around 35ms. –  DerMike Apr 18 '12 at 12:28

1 Answer 1

up vote 3 down vote accepted

Try this instead ;)

while true; do ping -c 1 <host> | awk '{print $1}'; done

Must be something about how ping terminates lines.

share|improve this answer
2  
Or possibly a lack of flushing. (which is just unhygienic imo) –  Eroen Apr 18 '12 at 10:58
    
Nice work around. +1 –  DerMike Apr 18 '12 at 12:30

Your Answer

 
discard

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.