awk field (was Re: (no subject))
Warren Block
wblock at wonkity.com
Wed Apr 8 15:11:22 PDT 2009
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
More information about the freebsd-questions
mailing list