The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 06:27 AM
How to get the count only if two column matches? gobinath Shell Programming and Scripting 3 05-27-2008 05:01 AM
How to count pattern in column ahjiefreak Shell Programming and Scripting 12 12-04-2007 07:53 PM
collect data from another file bikas_jena Shell Programming and Scripting 3 11-22-2007 03:27 AM
Max column count in a file gemini Shell Programming and Scripting 2 08-24-2004 01:12 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-25-2009
nirmal84 nirmal84 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
How to collect count of a column from log file??

Hi All,

I have an Output from a log file which is something like as follows..

***** CDR and SDR Statistics****
Wed Feb 25 00:05:00 EST 2009
*********CDR and SDR QUEUE STATUS*****
Queue busy wait msgs
cdr 2 2 4
sdr 2 0 2
******CWAY CROSS STATISTICS***********
name state last op busy%
cdr.140 busy 0:05.11 68.3
cdr.141 busy 0:06.42 59.6
cdr.142 free 0:07.80 42.9
cdr.143 free 0:08.26 33.0
cdr.144 free 0:14.64 20.9
cdr.145 free 0:10.72 14.0
cdr.146 free 0:32.41 9.5
cdr.147 free 0:16.32 7.1
sdr.150 busy 0:06.31 69.8
sdr.151 free 0:02.74 59.3
sdr.152 busy 401.60 48.1
sdr.153 free 0:03.02 37.1
sdr.154 free 0:19.02 26.8
sdr.155 free 0:19.67 19.9
sdr.156 free 0:07.48 15.4
sdr.157 free 1108.35 13.0
sdr.158 free 0:17.44 9.8
sdr.159 free 0:13.70 8.3
sdr.160 free 0:20.50 7.1
sdr.161 free 0:14.14 6.1


This info is written to the log file every 5 minutes(same as the above one).

Requirement:

I need to get the count of the msgs for CDR and SDR Induvidually every hour in a sperate file .Is there an way to do this by some script.The name of the log file is mg_stat.log
  #2 (permalink)  
Old 02-25-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,334
Something like this?


Code:
awk '
$1=="cdr"{print $4}
$1=="sdr"{print $4}
' file

Regards
  #3 (permalink)  
Old 02-25-2009
nirmal84 nirmal84 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
Hi Franklin,

Thanks a lot for your reply..

should this be in the same script which produces this log or a differnt one??

awk '
$1=="cdr"{print $4}
$1=="sdr"{print $4}
' output.txt
  #4 (permalink)  
Old 02-25-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,334
Quote:
Originally Posted by nirmal84 View Post
Hi Franklin,

Thanks a lot for your reply..

should this be in the same script which produces this log or a differnt one??

awk '
$1=="cdr"{print $4}
$1=="sdr"{print $4}
' output.txt
You can use a separate script or at the end of the same script.

Regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0