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 -->
  #7 (permalink)  
Old 09-01-2008
r0bert r0bert is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 1
similar but more difficult promblem

Hi,

I have a similar problem where i need to count stretches of lower- and upper-case letters within words like

ttgggcTGGCCGCCCCCCAGggc
ttgggcTGGCCGCtgggcttCCCCCAGggc

the output could look like:

ttgggcTGGCCGCCCCCCAGggc lower 5 upper 12 lower 3
ttgggcTGGCCGCtgggcttCCCCCAGggc lower 5 upper 7 lower 6 upper 6 lower 3

any help would be appreciated,

best
robert




Quote:
Originally Posted by dcfargo View Post
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.