Search code examples
bashmacosawkcharactertr

Making ẞ lowercase on MacOS bash


I have a problem with lowercasing ß character on MacOS. In all tools which I use for lowercasing (gawk and tr, awk has problems with encoding) it is not lowercased at all. Other special characters are lowercased correctly. Could anyone have some solution for that?

Examples:

tr

echo üäößÜÄÖẞ | tr '[:upper:]' '[:lower:]'
üäößüäöẞ

gawk

echo üäößÜÄÖẞ | gawk '{print tolower($0)}'
üäößüäöẞ

Solution

  • Option 1: perl

    echo 'üäößÜÄÖẞ' | perl -CSD -ne 'print lc'
    

    enter image description here


    Option 2: tr

    echo üäößÜÄÖẞ | tr ẞ ß
    

    Because both and ß are completely 'different' characters, the common tools don't know the lowercase version.

    As @Thilo suggested, you could use tr [option] stringValue1 [stringValue2] to tell tr to 'replace' with an ß


    enter image description here