Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Taming non-terminating Bash processes.
dns-sd | while read -r line ; do ... done
Consider replacing the while loop with awk. This sort of thing is exactly what awk is good at:
BEGIN { FS = " "; count = 0; } NR > 5 { count++ print if ($3 != "3") { exit; } } END { printf("%d hosts found\n", count); }
Consider replacing the while loop with awk. This sort of thing is exactly what awk is good at:
You could also do it with GNU sed (you'll need the q or Q command for early exit, and that's a GNU extension---no idea if it's available on OS X).