From owner-freebsd-questions@FreeBSD.ORG Wed Apr 8 22:11:21 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8DD61065672 for ; Wed, 8 Apr 2009 22:11:21 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (wonkity.com [67.158.26.137]) by mx1.freebsd.org (Postfix) with ESMTP id A42BF8FC16 for ; Wed, 8 Apr 2009 22:11:21 +0000 (UTC) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.3/8.14.3) with ESMTP id n38MBKVO065619; Wed, 8 Apr 2009 16:11:20 -0600 (MDT) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.3/8.14.3/Submit) with ESMTP id n38MBKnp065616; Wed, 8 Apr 2009 16:11:20 -0600 (MDT) (envelope-from wblock@wonkity.com) Date: Wed, 8 Apr 2009 16:11:20 -0600 (MDT) From: Warren Block To: Len Conrad In-Reply-To: <200904082253.AA2466447562@mail.Go2France.com> Message-ID: References: <200904082253.AA2466447562@mail.Go2France.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (wonkity.com [127.0.0.1]); Wed, 08 Apr 2009 16:11:21 -0600 (MDT) Cc: freebsd-questions@freebsd.org Subject: awk field (was Re: (no subject)) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2009 22:11:22 -0000 On Wed, 8 Apr 2009, Len Conrad wrote: > > We need to print a line when the 3rd field (with trailing ";" delimiter) is, eg, exactly 5 lower case characters > > awk ' $3 ~ /^[a-z]{5,5};$/ {print $0} ' file > > ... doesn't work. > > Suggestions? Please give an example of the line this doesn't work on, and exactly what you want it to do. "{5}" is probably acceptable instead of "{5,5}". I don't do much awk, but here's a Perl example: perl -e '$x = "abcde;"; print "Yes\n" if $x =~ /^[a-z]{5};$/' -Warren Block * Rapid City, South Dakota USA