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