Search code examples
linuxbashtext

How to change case of a UTF file


I have a UTF file in uppercase, and I want to change all words to lowercase.

I have tried:

`tr '[:upper:]' '[:lower:]' < input.txt > output.txt`

But that changes only characters without an accent.


Solution

  • This is because the default character classes only work on standard ASCII, which does not include most of the international accented characters. If you have a defined set of those characters, the easiest way would be to simply add the mapping from special uppercase character to special lowercase character manually:

    tr 'ÄÖU[:upper:]' 'äöü[:lower:]'

    If you only have a few accented characters, this is workable.