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
how to check the variable values is blank julirani Shell Programming and Scripting 2 12-06-2008 05:24 PM
fill a NIL into the blank field happyv Shell Programming and Scripting 8 03-23-2007 04:49 AM
finding duplicate files by size and finding pattern matching and its count jerome Sukumar Shell Programming and Scripting 2 12-01-2006 04:20 AM
how to include field separator if there are blank fields? ReV Shell Programming and Scripting 19 07-13-2005 05:50 AM
awk: How to check if field is blank? yongho Shell Programming and Scripting 7 06-09-2005 12:35 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-12-2009
king007 king007 is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 2
finding field count escaping the blank values

Hi All

I have a file.Below are few records of the file.

sample.txt

CPS,ES,843232910001,ESF81462,W N LINDSAY LTD,01674840629,09-FEB-2009,23-FEB-2009,CDR735,ALL CALLS,01674840629
CPS,ES,843232670001,ESF81462,W N LINDSAY LTD,01674840629,09-FEB-2009,23-FEB-2009,CDR734,ALL CALLS,01674840608


I need to find the count of the 6th field and it should not consider the blank and null values.

say if the total number of records are 10 and in that the 6th filed has 4 values and others are blank then it should give only count as 4 and not 10.

Kindly let me know how to proceed.

Thanks
  #2 (permalink)  
Old 02-12-2009
ranjithpr ranjithpr is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 157
Try this one

cut -d',' -f6 sample.txt|tr -d " "|grep -vc "^$"
  #3 (permalink)  
Old 02-12-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,322
With awk:

Code:
awk -F, '$6>0{n++}END{print n}' file
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 12:04 PM.


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