Count of Field for Non-Empty


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Count of Field for Non-Empty
# 1  
Old 08-08-2008
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
# 2  
Old 08-08-2008
Something like this?

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

Regards

Last edited by Franklin52; 08-08-2008 at 12:25 PM.. Reason: count instead of print the lines
# 3  
Old 08-08-2008
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Count columns that are non-empty per line

The file is similar to the attached. Thousands of columns, delimiter is tab, with many columns containing free text and space separated. I want to get the count of columns with non-empty entries. eg.Col1=10, Col6=5, Col8=1 awk preferred (7 Replies)
Discussion started by: genehunter
7 Replies

2. Shell Programming and Scripting

How to remove empty field in a text file?

Hi all, I want to remove empty field in a text file. I tried to used sed. But it failed. Input: LG10_PM_map_19_LEnd 1000560 G AG AG LG10_PM_map_19_LEnd 1005621 G AG LG10_PM_map_19_LEnd 1011214 A AG AG LG10_PM_map_19_LEnd 1011673 T CT CT ... (3 Replies)
Discussion started by: huiyee1
3 Replies

3. Shell Programming and Scripting

How to detect empty field in awk ?

Hi ! programmers I have a need of detecting empty field in file my file looks like this 40.900|-71.600|1.6|20|1|1961|21.00|3.700||1|US|28035|10029370|31 40.900|-71.600|5.7|20|1|1961|21.00|3.700||1|US|28035|10029370|31 40.900|-71.600|7.8|20|1|1961|21.00|3.700||1|US|28035|10029370|31... (7 Replies)
Discussion started by: Dona Clara
7 Replies

4. Shell Programming and Scripting

print non empty column/field value

I have below file 25-09-2012 24-09-2012 19-09-2012 31-07-2012 30-04-2012 30-03-2012 ASIAEXFVNV N/A CEU 4 DMIRSOA N/A CAS 2 2 2 DMIRSOA N/A MIDMT 2 NFIAL22 N/A HVNY 11 11 11 NFIAL22 N/A NYAL3 11 11 11 NFIAL22 N/A NYCN 11 11 11 ... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

5. UNIX for Dummies Questions & Answers

remove empty field

Hi all ! I'm sure it is a basic question but I didn't find any threads that fit my need. How to remove empty fields with awk? Or in other words, how to shift all the fields after an empty field on the left? input: 1|2||3|4|5||6 wanted: 1|2|3|4|5|6 I tried: awk '{for(i=1; i<=NF;... (7 Replies)
Discussion started by: lucasvs
7 Replies

6. Shell Programming and Scripting

Format the file by deleting empty field

I have the test data with 10 column separated by comma and each column has more than 1000000 rows. Can anyone help me to find empty field in all columns and delete that empty field alone and lift that column up by one row. Data with empty field: A74203XYZ,A21718XYZ,A72011XYZ,A41095XYZ,... (7 Replies)
Discussion started by: zooby
7 Replies

7. Shell Programming and Scripting

count words and empty files

Hello, I will count words in a file (or more files) and count (if given up) empty files (test -z?), how can I do this? Like this: There are "108" words in "3" files There are "2" empty files Thanks for your reaction. Regards, Arjan Engbers (My English is not good, I hope you... (4 Replies)
Discussion started by: arjanengbers
4 Replies

8. Shell Programming and Scripting

How to print empty line when the a field is changed

Hi all, I have this input file .. BSS01 107 Swafieh 11/06/2008 12:06:57 BSS01 111 Ramada_Hotel 12/06/2008 11:37:20 BSS01 147 Kalha_Rep 11/06/2008 19:13:39 BSS01 147 Kalha_Rep ... (9 Replies)
Discussion started by: yahyaaa
9 Replies

9. Shell Programming and Scripting

Awk scrip to remove empty field

Hi I have a file which looks like this name: Sally group: Group4 name: Tim group: Group1 name: Dan group: Group2 name: Chris group: Group3 name: Peter group: name: Fred group: name: Mary group: Group2 Well I want to get rid of the... (4 Replies)
Discussion started by: bombcan
4 Replies

10. UNIX for Dummies Questions & Answers

Shell Script using Join, empty field help!

Deleted#### (1 Reply)
Discussion started by: tibbyuk
1 Replies
Login or Register to Ask a Question