case conversion in sed substitution does not work

Erik Bågfors zindar at
Thu Nov 4 09:02:06 UTC 2004

In the first case you are looking for the characters a-z and turn them
to upper case, your search does not include a space, hence it stops at
the first space. The correct regex is

echo dennis decker jensen | sed -re 's/[a-z ]+/\U&/'

Note the space after the z.

In the second case if you only want to convert the first D use

echo dennis decker jensen | sed -re 's/[a-z]/\U&/' 
Dennis decker jensen

I don't think there is anything wrong with sed, just how you use the regex.

Also note that regex's sometimes are different between different
programs/languages. Perl regex's can do more than sed regex's for


On Wed, 03 Nov 2004 00:29:12 +0000, Dennis Decker Jensen
<dennisdjensen at> wrote:
> Package: sed
> Version: 4.1.2-1
> Severity: normal
> case 1:
> echo dennis decker jensen | sed -re 's/[a-z]+/\U&/'
> DENNIS decker jensen
> case 2:
> echo dennis decker jensen | sed -re 's/[a-z]+/\u&/'
> ennis decker jensen
> I expected this in case 2:
> Dennis decker jensen
> It eats the character! The same thing happens when using \l (\L).
> -- System Information:
> Debian Release: testing/unstable
> Architecture: i386 (i686)
> Kernel: Linux
> Locale: LANG=en_DK, LC_CTYPE=en_DK
> Versions of packages sed depends on:
> ii  libc6              2.3.2.ds1-13ubuntu2.2 GNU C Library: Shared libraries an
> -- no debconf information
> --
> ubuntu-users mailing list
> ubuntu-users at

More information about the ubuntu-users mailing list