count data separate by comma


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting count data separate by comma
# 1  
Old 04-24-2007
Lightbulb count data separate by comma

hi experts,

i have some problem with count data which separate by comma, below sample data :

01,011222823b6d,011222823f29,0028a5,002993,6212345678,
659111111111,6598204507,6281105008,6596197849,_,525016160836958,_,
ffffffff,000000000000000000000000,_,_,_,fd,fd,ff,00,1,0028a5-002993,_,
ff,8,3b7,_,_,80005ea,_,_,_,_

one day file have about 12000 files at log files i want to count how much having "01" and "_" and "000000000000000000000000" and "659111111111" line by line in a files.

the log file have two format in the directory, example :
/200704/20070401/ABC_2007040100-2007040101
/200704/20070401/ABC_2007040100-2007040101.out

i want only count without .out files.

nb:one directory have about 12000 files

please help

Thank you so much

Best Regards,

bucci

Last edited by reborg; 04-24-2007 at 01:32 PM.. Reason: disable smiley
# 2  
Old 04-24-2007
Code:
awk -F"," ' {
   for( i = 1 ; i <= NF ; ++i )
   {
     if( $i == "01" || $i == "659111111111" || $i == "000000000000000000000000" || $i == "_" )
     {		
	arr[FILENAME]++;
	break;
     }
   }
}
END {  for( file in arr ) { print file ":" arr[file] } }
' *.out

# 3  
Old 04-24-2007
Hi Anbu,

thank you for you quick response very appreciate, but when i run the syntax i got an error like this : "Arguments too long".

fyi, one day have about 12000 files.

actually, i want to count only line which have "01" and "000000000000000000000000" in column 15 and "_" in column 16 line by line

please advice

Thank you

Best Regards,

bucci

Quote:
Originally Posted by anbu23
Code:
awk -F"," ' {
   for( i = 1 ; i <= NF ; ++i )
   {
     if( $i == "01" || $i == "659111111111" || $i == "000000000000000000000000" || $i == "_" )
     {		
	arr[FILENAME]++;
	break;
     }
   }
}
END {  for( file in arr ) { print file ":" arr[file] } }
' *.out

# 4  
Old 04-24-2007
Code:
for file in *.out
do
  awk -F"," ' {
   $15 == "01" || $15 == "000000000000000000000000" && $16 == "_" { arr[FILENAME]++; }
   END {  for( file in arr ) { print file ":" arr[file] } }
  ' $file
done

# 5  
Old 04-24-2007
hi Anbu,

sorry have a little mistake info, i means is want to count file by file and in file line by line which in the files data only have "01" in column 1 and "000000000000000000000000" in column 15 and "_" in column 16, the data in each files created can have different like in other file can have "000AB04" in column 16 or "00000000000000000000A74B" in column 15 but all count is reference to "01" in column 1.

lets say filename is ABC_2007040100-2007040105, ABC_2007040105-2007040110,etc

note : the file is created each 15 minutes

please help with simple script thanks

please advice


Thank you so much

Best Regards,

bucci




Quote:
Originally Posted by anbu23
Code:
for file in *.out
do
  awk -F"," ' {
   $15 == "01" || $15 == "000000000000000000000000" && $16 == "_" { arr[FILENAME]++; }
   END {  for( file in arr ) { print file ":" arr[file] } }
  ' $file
done

# 6  
Old 04-25-2007
I dont get your requirement.Can you sample output?
# 7  
Old 04-25-2007
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


Quote:
Originally Posted by anbu23
I dont get your requirement.Can you sample output?
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