[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
field separators and filters
From: |
Thomas Meller |
Subject: |
field separators and filters |
Date: |
Mon, 11 Jun 2007 10:35:48 +0200 |
Hello together,
this is not the first time I stumble into this problem.
Neither books nor the official gnu guide could help me on that matter.
First of all: I am new to awk, learning from the official guide.
I want to filter all lines in a file beginning with a number between START and
END.
Here is an example:
awk -v begin=1175290897 -v end=1175294497 'BEGIN { IFS=":" }
$1 <= end && $1 > begin { print $0 }' audit_archive.table
address@hidden insert]$ tail -4 audit_archive.table
1175294497: 2007/03/31::00:41:37~009997~2007/03/31::00:41:37.203...trash
1175294497: 2007/03/31::00:41:37~009998~2007/03/31::00:41:37.016...trash
1175294497: 2007/03/31::00:41:37~009999~2007/03/31::00:41:37.000...trash
1175294497: 2007/03/31::00:41:37~010000~2007/03/31::00:41:37.234...trash
address@hidden insert]$
Result: the lines above are not printed. '<=' seems to be handled like '<'.
(same seems to be for '>=')
I tried some things and found that if the number from the file contains a ':',
i.e. the field separator, and this colon is contained in '$1', then gawk
behaves exactly like this case. (in another case I forgot to specify IFS ->
same result)
A workaround would be to increase the filter criteria by one, but that stinks!
Where is the bug? In front of the keyboard or behind it?
Version is gawk-3.1.3-10.1.
Used on Redhat EL 4
I already tried some lot to specify 'begin' and 'end' quoted, unqouted, inside
the BEGIN section and all other combinations. The result keeps the same all the
time.
Lines containing 1175294496: are printed, those with 1175294497: not.
THX alot. Documentation about awk is rare nowadays.
Tom
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
- field separators and filters,
Thomas Meller <=