Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to test for capital letter occurence?

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

in a loop

for i in .....


how test/check id $i has any capital letter?
 
case $i in *[A-Z]*) echo $i has capital letter;; esac

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
echo $i|grep -q '[A-Z]'
if [ $? -eq 0 ]
then
echo $i has one or more capitals
fi

HTH,

p5wizard
 
Code:
for i in one tWo three
do
  typeset -l TEST
  TEST=$i
  [[ $i = $TEST ]] || echo $i has caps
done

Columb Healy
 
Here's another one for the collection
Code:
for i in *
do
  expr index $i ABCDEFGHIJKLMNOPQRSTUVWXYZ >/dev/null && echo $i has caps
done
I'd like to have got rid of tha ugly ABCDEFGHIJKLMNOPQRSTUVWXYZ string but I'm not that good with expr.

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top