From owner-freebsd-questions@FreeBSD.ORG Fri Jul 15 03:43:55 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE50116A41C for ; Fri, 15 Jul 2005 03:43:55 +0000 (GMT) (envelope-from hzs202@gmail.com) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 351C443D49 for ; Fri, 15 Jul 2005 03:43:55 +0000 (GMT) (envelope-from hzs202@gmail.com) Received: by rproxy.gmail.com with SMTP id r35so657118rna for ; Thu, 14 Jul 2005 20:43:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:organization:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:x-enigmail-version:x-enigmail-supports:content-type:content-transfer-encoding; b=OM98ZQPn+GPRh2RrGUJjKS0KBnDrgBY5Aom4o64EruEsRUeMJIeL+0ZytGG14sN9EX9Vu+eatgEDxApvMMOsoQ0yXXT+AiV0Jllkyp5qLsjIX+n11tB4sQMIP52kl1zRB7LCQwOYFV+0YkNDflBrSpOUYCEg6SafhClYpVYGmVc= Received: by 10.38.151.73 with SMTP id y73mr2575041rnd; Thu, 14 Jul 2005 20:43:54 -0700 (PDT) Received: from ?192.168.10.3? ([66.65.10.203]) by mx.gmail.com with ESMTP id g2sm3408530rne.2005.07.14.20.43.40; Thu, 14 Jul 2005 20:43:54 -0700 (PDT) Message-ID: <42D730EB.6070905@gmail.com> Date: Thu, 14 Jul 2005 23:43:39 -0400 From: Hakim Singhji Organization: New York University User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <42D7236A.6010803@gmail.com> <20050715032319.GA98600@dan.emsphone.com> In-Reply-To: <20050715032319.GA98600@dan.emsphone.com> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Dan Nelson Subject: Re: Problem Piping iostat -c to awk! X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: hzs202@nyu.edu List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2005 03:43:56 -0000 -----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-----