awk question



Len Conrad <lconrad@xxxxxxxxxxxxx> 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
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Lengthy merge code
    ... Do any of your data fields contain any of the delimiter characters (i.e. the ... the chances are that the problem has nothing to do with memory. ... proprietary software package - I don't dare name it - and the merge ...
    (microsoft.public.word.mailmerge.fields)
  • Re: URLScan
    ... You state that "The delimiter of the log file is defined by W3C ... whitespace, not space characters: ...
    (microsoft.public.inetserver.iis.security)
  • Re: WORD factors Was: Re: RFD: Legacy Wordset
    ... delimiters other than BL while available to implementers, ... |characters shall be treated the same as the space character. ... character set are defined in this Standard as control characters. ... If the delimiter is the space character, hex 20, control characters ...
    (comp.lang.forth)
  • Re: [man bash] section "Word Splitting" - IFS
    ... > sing explanation of IFS varible in EXPANSION section, ... then any sequence of IFS characters serves to delimit words. ... >> also treated as a delimiter. ...
    (comp.unix.shell)