Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Apr 2009 16:11:20 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Len Conrad <lconrad@Go2France.com>
Cc:        freebsd-questions@freebsd.org
Subject:   awk field (was Re: (no subject))
Message-ID:  <alpine.BSF.2.00.0904081606500.65423@wonkity.com>
In-Reply-To: <200904082253.AA2466447562@mail.Go2France.com>
References:  <200904082253.AA2466447562@mail.Go2France.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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