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

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

Jens M Andreasen:
> On Sat, 2008-09-27 at 00:03 +0200, Wolfgang Woehl wrote:
> > 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/'
>
> While you are at it, could you explain that last sentence once more
> for those in the audience that did not get it the first time?

^. is the 1st char, put into () (protected with \) to store in \1
which gets uppercased with \U.

Julien wanted monday -> Mon, it seems. That's what the cut does: take
three bytes. We can loose the cut, too:

echo monday | sed 's/\(^.\)\(..\).*/\u\1\L\2/'

which matches 2 more characters and lowercases those with \L

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:05 2008

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