Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Apr 2009 15:32:51 +0200 (CEST)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-questions@FreeBSD.ORG, lconrad@Go2France.com
Subject:   awk question
Message-ID:  <200904091332.n39DWpDs037047@lurza.secnetix.de>
In-Reply-To: <200904082253.AA2466447562@mail.Go2France.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Len Conrad <lconrad@go2france.com> 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.  

If ";" is the delimiter character, you need to tell awk
about it (i.e. use the -F option).  This one should work:

awk  -F';'  '$3 ~ /^[a-z]{5}$/ {print}'  file

If that still doesn't work for you, please specify your
file format more exactly, and provide an example of the
input lines.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"anyone new to programming should be kept as far from C++ as
possible;  actually showing the stuff should be considered a
criminal offence" -- Jacek Generowicz



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