The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
count the number of field in a string with deliminter yang UNIX for Dummies Questions & Answers 9 07-25-2008 02:24 AM
How to print empty line when the a field is changed yahyaaa Shell Programming and Scripting 9 06-17-2008 07:31 AM
Awk scrip to remove empty field bombcan Shell Programming and Scripting 4 06-11-2008 09:57 AM
Shell Script using Join, empty field help! tibbyuk UNIX for Dummies Questions & Answers 1 02-25-2008 08:33 AM
Awk-Group count of field tinivt Shell Programming and Scripting 3 05-07-2007 12:44 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-08-2008
Registered User
 

Join Date: May 2008
Posts: 15
Count of Field for Non-Empty

Hi Guys,

I wanted to count the number of records for a particular field of a file. whose fields are separated by comma","

I fI use this command.
cat "filename" cut -sd "," -f13 | wc -l

This shows all the lines count including the blank values for the field number 13. I wanted to count record of field which are non-empty.

Kindly help me out.

Swapna
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-08-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,965
Something like this?

Code:
awk -F, '$13{c++}END{print c}' file
Regards

Last edited by Franklin52; 08-08-2008 at 08:25 AM. Reason: count instead of print the lines
Reply With Quote
  #3 (permalink)  
Old 08-08-2008
Registered User
 

Join Date: Jul 2008
Posts: 26
hi ,

if you feel easy , you can also use

cat <filename> | cut -sd "," -f13 | grep -v " " | wc -l

and reduce the count by 1

Rgds,
JeganR
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0