Error type order


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error type order
# 1  
Old 06-19-2012
Error type order

Hi all,
Sample data file...

Code:
9f680197||y|a|6
9f6801||6
9f68017|20120511|y|6
9f68017|y|1
9f68017|6
9f68017|20120511|N|2
9f68017|MD|212343907|20120511|N|2
9f68017212343907|20120511|N|2
9f68017N|3
9f68017|20120511|y|3
9f68017|MD|212343907|20120511|N|3
9f68017|MD|212343907|20120511|y|3
9f68017|N|4
9f68017|y|4
9f68017|N|4
9f68017|20120511|y|4
9f68017|Y|4
9f68017|N|4
9f68017|MD|212343907|20120511|n|4
9f68017|Baltimore|MD|212343907|20120608|N|4

if i use this command ,output as below

Code:
nawk -F "|" '{a[$NF]++;}END{for(i in a)print "Error type "i":", a[i];}' test.txt

Code:
Error type 2: 3
Error type 3: 4
Error type 4: 8
Error type 6: 4
Error type 1: 1

excepted output is
Code:
Error type 1: 1
Error type 2: 3
Error type 3: 4
Error type 4: 8
Error type 6: 4

Please help me...

Thanks,
# 2  
Old 06-19-2012
The
Quote:
for (i in arr)
construct does not select "i" in any particular order...

A workaround would be :

Code:
nawk -F "|" '{if($NF>max)max=$NF;a[$NF]++;}END{for(i=1;i<=max;i++)if(a[i]) print "Error type "i":", a[i];}' test.txt


Last edited by elixir_sinari; 06-19-2012 at 08:07 AM..
# 3  
Old 06-19-2012
Hi,

You could try;

Code:
nawk -F "|" '{a[$NF]++;}END{for(i in a)print "Error type "i":", a[i];}' test.txt | sort

Regards

Dave
# 4  
Old 06-19-2012
Working fine...
Thanks lot elixir_sinari and gull04
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Logical Error With Type Conversion In C

So, I'm into about 650 lines of some code I'm working on. So I'll try to explain instead of flooding this post. Say I have some code like this: int main() { int i, j; char data; printf("Gimme something: "); fgets(data, INPUT_BUFF, stdin); for (j = 0; j < data; j++){... (6 Replies)
Discussion started by: Azrael
6 Replies

2. Red Hat

What type of error is this?

:rolleyes::rolleyes::rolleyes: Jul 18 19:31:31 plbp1s sendmail: STARTTLS: read error=syscall error (-1), errno=104, get_error=error:00000000:lib(0):func(0):reason(0) ---------- Post updated at 03:08 AM ---------- Previous update was at 03:07 AM ---------- # cat /var/log/maillog|egrep -i... (2 Replies)
Discussion started by: manalisharmabe
2 Replies

3. UNIX for Dummies Questions & Answers

Build Error: error: dereferencing pointer to incomplete type

I'm getting the following Error: prepare_pcap.c: In function `prepare_pkts': prepare_pcap.c:127: error: dereferencing pointer to incomplete type prepare_pcap.c:138: error: dereferencing pointer to incomplete type ==================================== This is the part of the relevant... (8 Replies)
Discussion started by: katwala
8 Replies

4. SCO

Error: Value too large for defined data type

Hi all, I have this problem in one of the SCO UNIXWare 7.1.4. We have an application which is working on hundreds of machines. When we try to install the same application on a new machine, the executable/binary gives the following error and exits... "xxx startup failure: Value too large for... (1 Reply)
Discussion started by: chava01
1 Replies

5. Programming

error: field `fatx_i' has incomplete type

I'm trying to compile a 2.4.26 kernel but I have to apply two patches to it. The patches are: linux-2.4.26-xbox.patch openMosix-2.4.26-1 This is the reason that it doesn't compile. There is only one error but I'm not familiar with C or C++(Unfortunately only Java and some lower-level... (2 Replies)
Discussion started by: lateralus01
2 Replies

6. Programming

error: field has incomplete type

Hello there, Here is how it goes - I have written a small test driver as an exercise to "Linux Device Drivers" and as a preparation for writing a real, functional driver. For the sake of seeing how far I got it working (I already implemented the open(0, read(), write() and ioctl() calls) I... (4 Replies)
Discussion started by: boyanov
4 Replies

7. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

8. Solaris

Unknown File Type error

Greetings there, i was trying to install an eclipse plugin on sunOS 4.x for the solaris sparc platform, and i got the following error: /usr/project/RAServer/bin> ./RAStart.sh Starting Agent Controller ld.so.1: RAServer: fatal: /usr/project/RAServer/lib/libxerces-c.so.24: unknown file type... (3 Replies)
Discussion started by: rohitsz
3 Replies

9. Programming

Error : ANSI C++ forbids 'xx' declaration with no type

Hi All, I am not sure if this is the correct place to put this question but still i hope to get some info. I am compiling a c++ program on solaris 8 using c++ command, i get an error stating "ANSI C++ forbids declaration `genericerror' with no type" What could be the problem.... (2 Replies)
Discussion started by: zing
2 Replies
Login or Register to Ask a Question