6

I'm tryed with:

$ echo 'Ciência' | tr 'a-z' 'A-Z'
CIêNCIA

But the 'ê' character does not change, obviously because it is accentuated. Then I tried with POSIX classes:

echo "Ciência" | tr '[:lower:]' '[:upper:]'
CIêNCIA

But the 'ê' continue in lower case.

Could someone help me?

Patterson
  • 765
  • 1
    This has to do with the locale. What distro are you using? – Wildcard Oct 29 '16 at 01:07
  • I'm using Parrot GNU/Linux 3.2 CyberSloop, it's based on the latest stable Debian. – Patterson Oct 29 '16 at 01:13
  • Very odd. This works on Mac OS X without any fiddling, but I can't get it to work on my CentOS 6 test box no matter what I do with the locale. http://unix.stackexchange.com/q/128192/135943 is relevant here. – Wildcard Oct 29 '16 at 01:45
  • I think it's because my system is set to English, this should affect bash or whatever ... the environment variables ... Accents give me a headache and Portuguese is full of them for my bad luck. Well, the 'gawk' that Thomas Dickey suggested worked right! – Patterson Oct 29 '16 at 15:16

1 Answers1

6

You can do this with gawk:

echo "Ciência" | gawk '{print toupper($0);}'

(also perl, someone is certain to point out). The example uses UTF-8, which is not explicitly part of POSIX awk. gawk's documentation mentions these issues. For instance, both mawk and bwk (one-true-awk) give different results:

+ echo Ciência
+ gawk {print toupper($0);}
CIÊNCIA
+ echo Ciência
+ mawk {print toupper($0);}
CIêNCIA
+ echo Ciência
+ one-true-awk {print toupper($0);}
CIêNCIA
Thomas Dickey
  • 76,765
  • gawk or any POSIX-compliant awk (not mawk nor busybox awk though, the two other commonly found awk implementations on Linux-based systems). Why the intermediary x variable though? – Stéphane Chazelas Mar 11 '18 at 08:55