awk: record has too many fields

Hi,

I'm trying this command - but get this error.
Do you guys have any workaround for this?

cat tf|sed 's/{//g'|sed 's/,//g'|awk '{for (i=1;i<=NF;i++) {if ($i == "OPTIME") {k = i + 2; print $i,$k}}}'
awk: record `2005 Jul 28 17:35:29...' has too many fields
record number 15

This is how one record looks like:

2005 Jul 28 17:35:30:091 GMT 10 Adapter.Adapter Debug [Adapter] H3G_BMI-00000 Sending message on the Tib on subject DEV.Request._Null.Request.1: { { MTREE_PROPERTIES, {PROPERTY=^prefixList^, NODE={ {1, M_STRING, "/class/ae/Adapter_1/Common" } {default, M_STRING, "/class/ae/Adapter_1/Request" } }}}{^class^, M_STRING, "SMSCRequest" } {OTHER_ADDR_TON, M_INT, 1 } {OTHER_ADDR_NPI, M_INT, 4 } {CHARGED_ADDR_GLOBAL_TITLE, M_STRING, "04010" } {MSG_ID, M_STRING, "E9421401900" } {CHARGED_PARTY, M_INT, 0 } {CHARGED, M_BOOLEAN, false } {SMSC_ADDR, M_STRING, "004017" } {OTHER_LA, M_INT, 7778 } {CHARGED_ADDR, M_STRING, "202866" } {CHARGED_ADDR_PID, M_INT, 0 } {CHARGED_ADDR_GLOBAL_TITLE_PID, M_INT, 0 } {STORE_REF, M_INT, 0 } {OTHER_ADDR_PID, M_INT, 7 } {OTHER_ADDR, M_STRING, "010" } {CHARGED_ADDR_TON, M_INT, 1 } {CHARGED_ADDR_GLOBAL_TITLE_TON, M_INT, 1 } {COMMON_PARAMS, M_TREE, {^class^, M_STRING, "Commparameters" } {^idx^, M_INT, 1 } {OPERATION, M_INT, 3001 } {OPTIME, M_INT, 1129 } } {SINGLE_SHOT, M_BOOLEAN, false } {CHARGED_ADDR_NPI, M_INT, 1 } {CHARGED_ADDR_GLOBAL_TITLE_NPI, M_INT, 1 } {^tracking^, M_TREE, {^id^, M_STRING, "s3cvfTPIEiW8kU3cPunp0bthfU4e2" } {^1^, M_STRING, "BMIADAPTER." } {^2^, M_STRING, "" } {^3^, M_STRING, "BMIAdapter" } } }

You should consider gawk, but in this case you can do it all with sed...

sed -e 's/{//g' -e 's/,//g' -e 's/.*\(OPTIME\) [^ ]* \([^ ]*\) .*/\1 \2/' tf

Thanks Ygor,

BTW, whats the limit of fields in awk ?

Cheers!
Chaadana

Documentation here says 99 is the max value for NF:

http://www.unet.univie.ac.at/aix/cmds/aixcmds1/awk.htm

HPUX 11.0 awk supports 199. gawk on our old RH box is 255.

As you may guess, there are several versions of awk.