Changing case

You can have a variable expand into its value with all characters uppercase or lowercase using the "${myvar^^}" and "${myvar,,}" forms, respectively:

bash$ fn='mixedCase'
bash$ printf '%s\n' "${fn^^}"
MIXEDCASE
bash$ printf '%s\n' "${fn,,}"
mixedcase
Can you guess what the form with a single ^ or  , might do, rather than a double one? Try it out.

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.