In the last episode (Jul 14), Hakim Singhji said:
> I am having problems with a shell script that I am writing. I am
> looking to pipe the output of iostat to awk however the shell is
> hanging... even at the command line it hangs. The code looks like
> this:
> 
>       # iostat -c 300 2 | egrep -v '[a-zA-Z]|^$' | awk '{print $1}'
> 
> This code hangs for me... now when I just pipe iostat through the
> egreped patter it is fine. It's when it is passed to awk that I have
> problems... now of course if I simplify the output to:
> 
>       # iostat | egrep -v '[a-zA-Z]|^$' | awk '{print $1}'
> 
> it works just fine... so it has to be the awk. What is the problem?

Actually grep is the culprit.  It buffers its output when piped to
another program for efficiency.  Try adding --line-buffering, or just
let awk handle your regular expression:

iostat -c 300 1 | awk '!/[a-zA-Z]|^$/ {print $1}'


-- 
        Dan Nelson
        [EMAIL PROTECTED]
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to