![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| word count wc | chaandana | UNIX for Dummies Questions & Answers | 5 | 05-05-2009 10:47 AM |
| specified word count | bhaviknp | Shell Programming and Scripting | 5 | 02-27-2008 11:23 AM |
| Word count problem | ssmith001 | UNIX for Dummies Questions & Answers | 1 | 01-02-2007 01:21 PM |
| count word | ariuscy | UNIX for Dummies Questions & Answers | 1 | 10-13-2005 12:36 AM |
| How do I count # of char. in a word? | xadamz23 | Shell Programming and Scripting | 9 | 11-12-2003 12:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
another way to do this
Code:
# cat aaa aabbccddDDCCDDCCaabbcc 123 CCaaCCBBCCaaaaaaaCCCaa 234 CCDDCCAACCCCccccccccaa 999 # for i in `cut -f1 aaa -d ' '`; do echo -n "$i "; echo -n $i | sed 's/[^a-z]//g' | wc -c; done aabbccddDDCCDDCCaabbcc 14 CCaaCCBBCCaaaaaaaCCCaa 11 CCDDCCAACCCCccccccccaa 10 |
|
||||
|
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:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|