Date: Thu, 14 Jul 2005 23:43:39 -0400 From: Hakim Singhji <hzs202@gmail.com> To: freebsd-questions@freebsd.org Cc: Dan Nelson <dnelson@allantgroup.com> Subject: Re: Problem Piping iostat -c to awk! Message-ID: <42D730EB.6070905@gmail.com> In-Reply-To: <20050715032319.GA98600@dan.emsphone.com> References: <42D7236A.6010803@gmail.com> <20050715032319.GA98600@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dan, | iostat -c 300 1 | awk '!/[a-zA-Z]|^$/ {print $1}' This doesn't seem to work for me... awk tells me: awk syntax error at source line 1 *** /[a: Event not found. Not sure how to allow awk to delete two top rows of iostat... other that the grep option -v. Does not seem to be working in awk. Dan Nelson wrote: | 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}' | | - -- Hakim Singhji New York University "But where danger is, grows the saving power also" (qtd. in Heidegger 28). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFC1zDrs2AZ6g3dZu8RAqfuAJ48mZRADvVcMHV8WtJJnNKdYNbMSACePPuh 0k0t6z262s40C0+PMarYAV4= =NP1k -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42D730EB.6070905>