changing upper/lower case with tr

August 4th, 2006 mysurface Posted in Text Manipulation, tr | Hits: 37263 | 2 Comments »

tr is actually a common translator, here I show you how to convert

string from uppercase to lowercase

echo "UPPER" | tr [A-Z] [a-z]

from lower to upper

echo "lower" | tr [a-z] [A-Z]

[中文翻译]

2 Responses to “changing upper/lower case with tr”

  1. you need quotes on some linux (ubuntu)

    echo “UPPER” | tr “[A-Z]” “[a-z]“

  2. tr ‘[[:upper:]]’ ‘[[:lower:]]’

    or

    tr ‘[[:lower:]]’ ‘[[:upper:]]’

Leave a Reply