Whenever we work with textual strings, sooner or later the issue of case comes up. Does a word need to be fully uppercase, fully lowercase, with a capitalized letter at the start of the word or sentence, and so on.
An idiom is a natural language expression of a simple programming task. For example, in the
sleep 10 command (which will pause the terminal one is working in for ten seconds), the word
sleep is a natural language expression of what is a time based coding construct, developed in the Bash GNU coreutils software package.
There are a number of special variable-bound idioms (i.e. suffixes which can be added to a variable name, indicating what we would like to do with a given variable), which can be used in Bash to more easily do these types of conversions on the fly instead of having to use for example the Sed Stream Editor with a Regular Expression to do the same.
If you are interested in using regular expressions, have a look at our Bash Regexps For Beginners With Examples Advanced Bash Regex With Examples articles!
This makes working with variables that need case modification, or
if statement testing a whole lot easier and provides great flexibility. Idioms can be added directly inside the
if statements and do not need to employ a subshell with
While the syntax looks slightly complex to start with, once you learn a little mental support trick to remember the right keys, you will be well on your way to use these idioms in your next script or Bash one-liner script at the command line!
In this tutorial you will learn:
- How to use the
,, Bash variable suffix idioms
- How to use a regular expression
 range idiom in combination with these
- How to use the
, idioms directly from within
- Detailed examples exemplifying the use of