awk: record has too many fields


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk: record has too many fields
# 1  
Old 07-28-2005
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" } } }
# 2  
Old 07-28-2005
You should consider gawk, but in this case you can do it all with sed...
Code:
sed -e 's/{//g' -e 's/,//g' -e 's/.*\(OPTIME\) [^ ]* \([^ ]*\) .*/\1 \2/' tf

# 3  
Old 07-28-2005
MySQL great

Thanks Ygor,

BTW, whats the limit of fields in awk ?

Cheers!
Chaadana
# 4  
Old 07-29-2005
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

2. Shell Programming and Scripting

Delete last 2 fields from every record in a file

Sample file record : "20130617003","2013-06-18T07:00:03","OUTWARD","01001011","TEST PLC","","HFX834346364364","20130617","10","DUM87534758","","1.28","826","020201","65879278","","","","","","010101","56789","DUMMY... (3 Replies)
Discussion started by: bigbuk
3 Replies

3. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

4. Shell Programming and Scripting

Compare fields and keep record with bigger ID?

How do you write a shell script to compare records with the same fields then keep the biggeer id number fields (field separate by a pipe) 1150| San Jose|8|15|7|2013-02-19 00:00:00.000|2013-02-20 00:00:00.000 1263|San Jose|8|15|7|2013-02-19 00:00:00.000|2013-02-20 00:00:00.000... (4 Replies)
Discussion started by: sabercats
4 Replies

5. UNIX for Dummies Questions & Answers

keeping last record among group of records with common fields (awk)

input: ref.1;rack.1;1 #group1 ref.1;rack.1;2 #group1 ref.1;rack.2;1 #group2 ref.2;rack.3;1 #group3 ref.2;rack.3;2 #group3 ref.2;rack.3;3 #group3 Among records from same group (i.e. with same 1st and 2nd field - separated by ";"), I would need to keep the last record... (5 Replies)
Discussion started by: beca123456
5 Replies

6. Shell Programming and Scripting

Print all the fields of record using awk

Hi, i want to generate print statement using awk. i have 20+ and 30+ fields in each line Now its priting only first eight fields print statement as output not all. my record is as shown below filename ... (2 Replies)
Discussion started by: raghavendra.nsn
2 Replies

7. Shell Programming and Scripting

awk text record - prepend first field to all subsequent fields

Hello everyone, I've suddenly gotten very interested in sed and awk (and enjoying it quite a bit too) because of a large conversion project that we're working on. I'm currently stuck with a very inefficient process for processing text blocks. I'm sure someone here should be able to easily point out... (2 Replies)
Discussion started by: jameswatson3
2 Replies

8. Shell Programming and Scripting

Making changes in the fields of a record

:confused: Hi Friends, In the record below i have to make changes in the fields by putting the values stored in the temporary variables, x, y, z, p, q, r: 2) In the TBT record store the values in the various fields as: a) X in a field position 51 to 56 b) Y... (5 Replies)
Discussion started by: kanu_pathak
5 Replies

9. Shell Programming and Scripting

How count number of fields in a record

Dear All , I have the query cat temp.txt |28-07-1997|IF_LEG_DCCT|TOV JV sdfsdfdsfdsfdsCLOSED* KIEV|381015280 I need to count the number of fields in this pipe-seperated file. I beleive this is possible via AWK command. The in above file, output of the count should be 5.... Can some-one... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

10. Shell Programming and Scripting

Manipulating fields record wise

Hi all, I have an input file with no delimiter. Let us say the file is abc.txt having values for fields namely, EmpNumEnameDesigSalDept. Ofcourse the file has got several records. Every field has got a fixed start and end position. I need to assign the fields to corresponding varibles say... (1 Reply)
Discussion started by: rinku11
1 Replies
Login or Register to Ask a Question