Issue
I have a very long file with a format of column_name=column_val, column_name2=column_val2
and so on.
the columns are not in the right order, lets say for example i have this file:
bar=x moshe=foo test=x duration=5
moshe=foo2 test=y duration=0 bar=y
duration=3 moshe=foo3 bar=z test=x
i want to return lines only where duration is greater then 2
as far as I know awk
is not optional since i can't tell where the columns are location in each line.
on IRC in #bash
channel someone recommended using gawk's match(). there too i was having problem seeing how to resolve this while each line the duration is elsewhere.
any ideas?
thanks
Solution
Extract the data with regex and compare.
awk '0+gensub(".*duration=([0-9]*).*", "\\1", "1") > 2'
@edit as above, the 0+
is needed to convert string to integer.
Answered By - KamilCuk