Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2005 23:03:16 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        hzs202@nyu.edu
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Problem Piping iostat -c to awk!
Message-ID:  <20050715040316.GB98600@dan.emsphone.com>
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
In the last episode (Jul 14), Hakim Singhji said:
> 
> | 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.

You're probably running csh or tcsh, which try and interpret the !
character even in quotes.  It'll work in a script, but on the
commandline you'll need to change it to \! . Alternatively, you can
print only lines with leading spaces followed by a number with:

iostat -c 300 1 | gawk '/^ +[0-9]/ {print $1}'

-- 
	Dan Nelson
	dnelson@allantgroup.com



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