Marc
Marc

Reputation: 640

Bash uppercase words that start with non-latin letters

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?

Upvotes: 1

Views: 59

Answers (1)

Cyrus
Cyrus

Reputation: 88664

I suggest:

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

Output:

Ängstlich

Upvotes: 4

Related Questions