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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to sort, and count unique data all at once? amatuer_lee_3 Shell Programming and Scripting 13 05-15-2008 07:48 AM
Separate string arghya_owen Shell Programming and Scripting 3 05-14-2008 12:35 AM
How to count the record count in an EBCDIC file. oracle8 UNIX for Dummies Questions & Answers 1 07-26-2006 04:22 PM
separate out the column ust Shell Programming and Scripting 6 12-29-2005 03:11 AM
How to separate a variable whatisthis Shell Programming and Scripting 4 11-02-2004 09:49 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Sep 2006
Posts: 81
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 09:32 AM. Reason: disable smiley
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
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
Reply With Quote
  #3 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Sep 2006
Posts: 81
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
Reply With Quote
  #4 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
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
Reply With Quote
  #5 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Sep 2006
Posts: 81
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
Reply With Quote
  #6 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
I dont get your requirement.Can you sample output?
Reply With Quote
  #7 (permalink)  
Old 04-25-2007
Registered User
 

Join Date: Sep 2006
Posts: 81
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?
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0