| Chris F.A. Johnson 2005-04-25, 5:53 pm |
| On Mon, 25 Apr 2005 at 04:03 GMT, Hans Horn wrote:
> Group,
> is there a simple way to convert just the first char of a word to uppercase?
With a POSIX shell, no external command is necessary:
case $word in
a*) l=A ;; b*) l=B ;;
c*) l=C ;; d*) l=D ;;
e*) l=E ;; f*) l=F ;;
g*) l=G ;; h*) l=H ;;
i*) l=I ;; j*) l=J ;;
k*) l=K ;; l*) l=L ;;
m*) l=M ;; n*) l=N ;;
o*) l=O ;; p*) l=P ;;
q*) l=Q ;; r*) l=R ;;
s*) l=S ;; t*) l=T ;;
u*) l=U ;; v*) l=V ;;
w*) l=W ;; x*) l=X ;;
y*) l=Y ;; z*) l=Z ;;
esac
cword=$l${word#?}
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========================================
==========================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/ssr.html>
|