|
|
|
|
|
by ttwwmm
4246 days ago
|
|
The use of <(..) is really weird here... why not just pipe dns-sd to the while loop? dns-sd | while read -r line ; do
...
done
Sure, you won't be able to accumulate the output for the trap, but you shouldn't need to---this is stream processing!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); }
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). |
|