If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Count # or occurences...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-04, 09:40
TimoV TimoV is offline
Registered User
 
Join Date: Dec 2003
Posts: 56
Count # or occurences...

I have the following file:

Quote:
4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
DED8E752 0222075604 T H ent1 ETHERNET DOWN
4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
DED8E752 0222075604 T H ent1 ETHERNET DOWN
4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
DED8E752 0222075404 T H ent1 ETHERNET DOWN
BFE4C025 0222073404 P H sysplanar0 UNDETERMINED ERROR
B6048838 0218154304 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
5DFED6F1 0218143004 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
5DFED6F1 0218142404 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
C092AFE4 0217154204 I O ctcasd ctcasd Daemon Started
A6DF45AA 0217154204 I O RMCdaemon The daemon is started.
2BFA76F6 0217153904 T S SYSPROC SYSTEM SHUTDOWN BY USER
9DBCFDEE 0217154104 T O errdemon ERROR LOGGING TURNED ON
192AC071 0217153804 T O errdemon ERROR LOGGING TURNED OFF
B6048838 0210135704 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
C092AFE4 0206162604 I O ctcasd ctcasd Daemon Started
A6DF45AA 0206162504 I O RMCdaemon The daemon is started.
2BFA76F6 0206162204 T S SYSPROC SYSTEM SHUTDOWN BY USER
9DBCFDEE 0206162404 T O errdemon ERROR LOGGING TURNED ON
192AC071 0206162104 T O errdemon ERROR LOGGING TURNED OFF
C092AFE4 0130155804 I O ctcasd ctcasd Daemon Started
Now I need to create a counter that counts whenever colum 1 and 2 are the same for 2 lines.

So I would need an output like:
2 DED8E752 0222075604 T H ent1 ETHERNET DOWN

Only those two colums need to be checked, but all fields and the counter must be returned.

Any ideas?


Thanx
Reply With Quote
  #2 (permalink)  
Old 02-25-04, 10:05
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Try this :

Code:
sort input_file | uniq -c
The result for your example datas :
Quote:
1 192AC071 0206162104 T O errdemon ERROR LOGGING TURNED OFF
1 192AC071 0217153804 T O errdemon ERROR LOGGING TURNED OFF
1 2BFA76F6 0206162204 T S SYSPROC SYSTEM SHUTDOWN BY USER
1 2BFA76F6 0217153904 T S SYSPROC SYSTEM SHUTDOWN BY USER
3 4507DE58 0222075604 I H ent1 ETHERNET NETWORK RECOVERY MODE
1 5DFED6F1 0218142404 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
1 5DFED6F1 0218143004 I O SYSPFS UNABLE TO ALLOCATE SPACE IN FILE SYSTEM
1 9DBCFDEE 0206162404 T O errdemon ERROR LOGGING TURNED ON
1 9DBCFDEE 0217154104 T O errdemon ERROR LOGGING TURNED ON
1 A6DF45AA 0206162504 I O RMCdaemon The daemon is started.
1 A6DF45AA 0217154204 I O RMCdaemon The daemon is started.
1 B6048838 0210135704 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
1 B6048838 0218154304 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED
1 BFE4C025 0222073404 P H sysplanar0 UNDETERMINED ERROR
1 C092AFE4 0130155804 I O ctcasd ctcasd Daemon Started
1 C092AFE4 0206162604 I O ctcasd ctcasd Daemon Started
1 C092AFE4 0217154204 I O ctcasd ctcasd Daemon Started
1 DED8E752 0222075404 T H ent1 ETHERNET DOWN
2 DED8E752 0222075604 T H ent1 ETHERNET DOWN
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-25-04, 10:36
TimoV TimoV is offline
Registered User
 
Join Date: Dec 2003
Posts: 56
Quote:
Originally posted by aigles
Try this :

Code:
sort input_file | uniq -c
Works like a charm! Thanx
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On