Re: first letter of the word in CAPS
On 2006-08-22, aarcee wrote:
> Hello all ,
>
> I need to display a word with the first character in CAPS .
You mean CAP, not CAPS, if it is only one character.
If you have the word in $word:
case $word in
a*) _UPR=A ;; b*) _UPR=B ;;
c*) _UPR=C ;; d*) _UPR=D ;;
e*) _UPR=E ;; f*) _UPR=F ;;
g*) _UPR=G ;; h*) _UPR=H ;;
i*) _UPR=I ;; j*) _UPR=J ;;
k*) _UPR=K ;; l*) _UPR=L ;;
m*) _UPR=M ;; n*) _UPR=N ;;
o*) _UPR=O ;; p*) _UPR=P ;;
q*) _UPR=Q ;; r*) _UPR=R ;;
s*) _UPR=S ;; t*) _UPR=T ;;
u*) _UPR=U ;; v*) _UPR=V ;;
w*) _UPR=W ;; x*) _UPR=X ;;
y*) _UPR=Y ;; z*) _UPR=Z ;;
*) _UPR=${1%${1#?}} ;;
esac
word=$_UPR${word#?}
printf "s\n" "$word"
> that is , split then the display should be Split
What display? Split how? Why?
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
|