count data separate by comma


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting count data separate by comma
# 8  
Old 04-25-2007
Quote:
Originally Posted by bucci
Hi anbu,

Thanks for you response

the sample output is like :

found "01" at column 1 and without "_" at column 16 count = 1000

found "01" at column 1 and with "00000000000000000000000" at column 15 count = 2000


please advice

Thank you

Best Regards,

pm.wu
Code:
for file in *.out
do
  awk -F"," ' 
   $1 == "01" && $15 == "000000000000000000000000" { zeros++ }
   $1 == "01" && $16 == "_" { underscore++ }
   END {  print "found "01" at column 1 and without "_" at column 16 count = " underscore 
	  print "found "01" found "01" at column 1 and with "00000000000000000000000" at column 15 count = " zeros
       }
  ' $file
done

# 9  
Old 04-25-2007
Bucci,
Try the following:
1) Starting with "01" and without "_" on column 15:
egrep -c '^01.............[^_]' input_file

2) Starting with "01" and with "00000000000000000000000" starting on column 15:
egrep -c '^01.............00000000000000000000000' input_file
# 10  
Old 04-26-2007
Hi Anbu,

Thanks for your help

it work

Thank you

Best Regards,

bucci

Quote:
Originally Posted by anbu23
Code:
for file in *.out
do
  awk -F"," ' 
   $1 == "01" && $15 == "000000000000000000000000" { zeros++ }
   $1 == "01" && $16 == "_" { underscore++ }
   END {  print "found "01" at column 1 and without "_" at column 16 count = " underscore 
	  print "found "01" found "01" at column 1 and with "00000000000000000000000" at column 15 count = " zeros
       }
  ' $file
done

# 11  
Old 04-26-2007
Hi,

Thanks for your suggestion

Best Regards,

bucci

Quote:
Originally Posted by Shell_Life
Bucci,
Try the following:
1) Starting with "01" and without "_" on column 15:
egrep -c '^01.............[^_]' input_file

2) Starting with "01" and with "00000000000000000000000" starting on column 15:
egrep -c '^01.............00000000000000000000000' input_file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to separate rows of data into another column?

I have data such as below where the value in second field is the same as that in the row after. 123456,22222,John,0,xyz 234567,22222,John1,1,cde 43212,3333,Jean,3,pip 84324,3333,Abel,2,cat I'd like to rearrange the output like below to put such records beside each other and separated with... (5 Replies)
Discussion started by: james2009
5 Replies

2. UNIX for Advanced & Expert Users

Comma separate issue in UNIX

In awk the field seprator is not working properly, I am trying to cut the fields from the file based on the delimiter example comma (,) awk -F, "{print {$1 FS $3 FS $5 FS FS $2}}" Sample.csv But i am not getting desired output can anyone help me how to check real ascii comma there in my... (9 Replies)
Discussion started by: rspwilliam
9 Replies

3. Shell Programming and Scripting

Separate Entries after comma

Hi All I need help to separate entries after commas in my I have 2 columns in my file like this Ramush, Shyam, Mohan First Ram, Mohan, Kaavya Second, Fourth Kavi, Ram, Shaym, Mohan Third I ahve to separate entries after comma in a separate row... (9 Replies)
Discussion started by: kareena
9 Replies

4. Shell Programming and Scripting

Remove bracket part entires and separate entries after comma

Hi all This time my input conatin 3 columns: ERCC1 (PA155) Platinum compounds (PA164713176) Allele A is not associated with response to Platinum compounds in women with Ovarian Neoplasms as compared to allele C . CES1 (PA107) methylphenidate (PA450464) Genotype CT is not... (4 Replies)
Discussion started by: Priyanka Chopra
4 Replies

5. Shell Programming and Scripting

Count and separate entries with N/A mentioned in front

Hi all, I have afile with following data I want to separate, count the entries with N/A in front of it so I will have all the entries with N/A in front seprate file . so output shuld be (7 Replies)
Discussion started by: manigrover
7 Replies

6. Shell Programming and Scripting

Count number of column in a comma delimited file

I have a comma (,) delimited file. 106232145,"medicare","medicare,medicaid",789 I would like to count the number of fields in each line. I tried the below code awk -F ',' '{print NF-1}' This returns me the result as 5 instead of 4. This is because the awk takes... (9 Replies)
Discussion started by: machomaddy
9 Replies

7. Shell Programming and Scripting

using diff to on two file but ignoring the last comma separate value

Hi guys I have two file which I sdiff. ie file 1: AA,12,34,56,,789,101,,6666 file 2: AA,12,34,56,,789,101,,7777 The last comma separated value will always change from one day to the next. Is there another unix utility I can use that will sdiff two files but ignore the last comma... (1 Reply)
Discussion started by: wny201
1 Replies

8. UNIX for Dummies Questions & Answers

Separate text files in a folder by word count

Hi, been searching Google for like an hour and I doubt I got the right keywords so might as well ask here. What I need: Before: Article1.txt 564 Article2.txt 799 Article3.txt 349 Article4.txt 452 * Separate files over 400 wordcount * After: Article1.txt 564... (3 Replies)
Discussion started by: Richard2000
3 Replies

9. Shell Programming and Scripting

Pull Data After Comma if 2 word before comma

Hi, I am trying to truncate word after comma in a file ONLY if there are already 2 words BEFORE comma. If there is one word or 3 or more words BEFORE comma, then I have to leave the data AS IS. See below for example. Input File : John Smith, Manager Smith, John Frank J F K... (2 Replies)
Discussion started by: msalam65
2 Replies

10. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies
Login or Register to Ask a Question