Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

29
  • 12
    Am I missing something, or does your last example (in Bash) actually do something completely different? It works for "ABX", but if you instead make word="Hi All" like the other examples, it returns ha, not hi all. It only works for the capitalized letters and skips the already-lowercased letters.
    – jangosteve
    Commented Jan 14, 2012 at 21:58
  • 31
    Note that only the tr and awk examples are specified in the POSIX standard. Commented Feb 3, 2012 at 18:55
  • 211
    tr '[:upper:]' '[:lower:]' will use the current locale to determine uppercase/lowercase equivalents, so it'll work with locales that use letters with diacritical marks. Commented Feb 3, 2012 at 18:58
  • 18
    How does one get the output into a new variable? Ie say I want the lowercased string into a new variable? Commented Sep 25, 2012 at 18:01
  • 88
    @Adam: b="$(echo $a | tr '[A-Z]' '[a-z]')"
    – Tino
    Commented Nov 14, 2012 at 15:39