The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Based on num of records in file1 need to check records in file2 to set some condns mavesum Shell Programming and Scripting 3 11-26-2008 10:48 AM
replaying a record count with another record count er_zeeshan05 Shell Programming and Scripting 2 10-30-2008 12:14 AM
Parsing records from one record bwrynz1 UNIX for Advanced & Expert Users 1 03-10-2008 10:54 AM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 12:15 PM
How to count the record count in an EBCDIC file. oracle8 UNIX for Dummies Questions & Answers 1 07-26-2006 07:22 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 03-03-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 75
Record count based on a keyword in the records

Hi,

Am having files with many records, i need to count and display the number of records based on the keyword in one of the column of the records.

for e.g THE FILE CONTAINS TWO RECORDS LIKE.

200903031143150 0 1236060795054357lessrv1 BSNLSERVICE1 BSNLSERVICE1 2128 FRAMEWORK slir 0 SUCCESS 919445393337 477 352 WGS84



200903031143150 0 1236060795054357lessrv1 RTMS RTMS 2128 FRAMEWORK slir 0 SUCCESS 919445393337 477 352 WGS84


I NEED TO COUNT THE NO OF RECORDS BASED ON COLUMN NO 4(BSNLSERVICE1) AND DISPLAY

CAN ANY ONE HELP ME OUT

AEMUNATHAN
  #2 (permalink)  
Old 03-03-2009
puneet's Avatar
puneet puneet is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 8
cat myfile | cut -f4 -d" " | grep mytext | wc -l

myfile will be the name of file in which you are searching
4 in f4 represents column 4
mytext is what I am searching
Regards
Puneet Khurana
  #3 (permalink)  
Old 03-03-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 75
am getting zero as the result...but records are there

cat 1236062198899.7372.tmp | cut -f5 -d "" | grep BSNLSERVICE1 | wc -l
0

cat 1236062198899.7372.tmp | cut -f4 -d "" | grep BSNLSERVICE1 | wc -l
0

Last edited by aemunathan; 03-03-2009 at 03:24 AM..
  #4 (permalink)  
Old 03-03-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Code:
$ cat log
200903031143150 0 1236060795054357lessrv1 BSNLSERVICE1 BSNLSERVICE1 2128 FRAMEWORK slir 0 SUCCESS 919445393337 477 352 WGS84
200903031143150 0 1236060795054357lessrv1 RTMS RTMS 2128 FRAMEWORK slir 0 SUCCESS 919445393337 477 352 WGS84

$ awk '{sum[$4]++;}END{for(i in sum) {print i, sum[i]}}' log
RTMS 1
BSNLSERVICE1 1
  #5 (permalink)  
Old 03-03-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 75
thanks ...its working fine
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 10:51 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