The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-25-2008
dcfargo dcfargo is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 45
Count lowercase in a word

I have a file like:


aabbccddDDCCDDCCaabbcc 123
CCaaCCBBCCaaaaaaaCCCaa 234
CCDDCCAACCCCccccccccaa 999

I'd like to print out the 1st word followed by the number of lowercase characters in that word. The words only consist of a few letters.

I was trying something like

awk '{a+=gsub(a,a) b+=gsub(b,b) c+=gusb(c,c) d+=(gsub(
d,d) x=(a+b+c+d) END {print $1, X}' infile >outfile


Thanks so much for your help.