Home > front end >  Bash uppercase words that start with non-latin letters
Bash uppercase words that start with non-latin letters

Time:11-04

I would like to Uppercase the first word of each line in a file. To do so, I can use one of the following commands:

sed 's/^./\u&/'

sed -E 's/[[:alpha:]] /\u&/1'

However, these commands do not uppercase words that start with non-latin letter such as ängstlich.

I tried exporting LC_ALL=C, but this did not solve the issue.

How can this problem be resolved?

CodePudding user response:

I suggest:

echo "ängstlich" | LC_ALL=de_DE.UTF-8 sed -E 's/[[:alpha:]] /\u&/1'

Output:

Ängstlich
  • Related