Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2005 00:09:46 -0400
From:      Paul Chvostek <paul+fbsd@it.ca>
To:        hzs202@nyu.edu
Cc:        Dan Nelson <dnelson@allantgroup.com>, freebsd-questions@freebsd.org
Subject:   Re: Problem Piping iostat -c to awk!
Message-ID:  <20050715040946.GA4827@it.ca>
In-Reply-To: <42D730EB.6070905@gmail.com>
References:  <42D7236A.6010803@gmail.com> <20050715032319.GA98600@dan.emsphone.com> <42D730EB.6070905@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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@it.ca>
  it.canada                                            http://www.it.ca/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050715040946.GA4827>