Re: [LAD] [ot] capitalising words in a shell-script

From: Wolfgang Woehl <tito@email-addr-hidden>
Date: Sat Sep 27 2008 - 01:03:11 EEST

Julien Claassen:
> Hi!
> Thank you all! I managed. there is something I didn't think of,
> which is, that you can output only part of shell-variables. Now it
> looks like this: VAR="Monday"
> tmp_first=`echo "${VAR:0:1}" | tr 'a-z' 'A-Z'`
> tmp_rest=`echo "${VAR:1}"
> tmp_rest_short=`echo "${VAR:1:2}"`
> var_long="$tmp_first$tmp_rest"
> var_short="$tmp_first$tmp_rest_short"
> echo "$var_long var_short"
> Monday Mon

Oh my god :)
This one is ugly too but, while we're at it, what the hell:
echo "monday" | cut -b -3 | sed 's/\(^.\)/\U\1/'

Wolfgang
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Sat Sep 27 04:15:04 2008

This archive was generated by hypermail 2.1.8 : Sat Sep 27 2008 - 04:15:04 EEST