Problem Piping iostat -c to awk!
Paul Chvostek
paul+fbsd at it.ca
Fri Jul 15 04:09:49 GMT 2005
On Thu, Jul 14, 2005 at 11:43:39PM -0400, Hakim Singhji wrote:
>
> | 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.
That's because you're using tcsh, and the exlcamation point is being
interpreted as part of a shell history reference. You can turn this
into a shell *script*, or just run it in bash or /bin/sh. Or if you
absolutely must run it in csh/tcsh, escape the ! with a \ (yes, even
inside single quotes).
> 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.
You could try something like:
iostat -c 300 | awk 'BEGIN {getline;getline;} $1~/^[0-9]+$/ {print $1}'
or for something even lighter-weight:
iostat -c 300 | sed -Ene 's/^ +//;s/ .*//;/^[0-9]+$/p'
--
Paul Chvostek <paul at it.ca>
it.canada http://www.it.ca/
More information about the freebsd-questions
mailing list