I'm trying to test the limits of the tr command using character ranges. What I don't get is how come I get the output:

lowercase letters

when typing:

echo "lowercase letters" | tr A-Z A-Z

instead of:



My locale is set to dictionary order aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ. In principle, the "a" in "lowercase letters" shouldn't be changed, since "a" comes before "A". The thing I don't get is how come the other letters in "lowercase letters" aren't capitalized? Shouldn't they all be capitalized given that they are all located between "A" and "Z" in dictionary order?

  • What's your locale ? Jul 9, 2017 at 1:56
  • @SergiyKolodyazhnyy LANG=en_US.UTF-8 Jul 9, 2017 at 1:57
  • Same as mine, but here it works OK and doesn't capitalize anything. Try it like echo "lowercase letters" | LC_ALL=C tr A-Z A-Z Does that give the same output ? Jul 9, 2017 at 2:01
  • @SergiyKolodyazhnyy Just to be clear, the output that I was expecting was the following: "LOWERCaSE LETTERS". Instead I got: "lowercase letters". I just tried doing "echo "lowercase letters" | LC_ALL=C tr A-Z A-Z" and it gave me the same "lowercase letters". Jul 9, 2017 at 2:05
  • Ah, wait , I think I see what's your confusion is. A-Z doesn't expand the dictionary order. It expands to all ascii characters from A to Z. Since in lowercase letters there's no capitals, nothing gets changed Jul 9, 2017 at 2:05

1 Answer 1


Because that is what it is supposed to do? You told tr to change any letters in the first set to the corresponding letters in the second set which you specify as identical, so why do expect a change at all? I can't see that locale is relevant. Even if it were sorting is some totally insane order, surely it would interpret "A-Z" the same way in both arguments. This seems so obvious to me, I have a bad feeling I'm being stupid and missing something.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .