Case modification

Next up is another parameter expansion we've already briefly seen: case modification. In this instance, case refers to lowercase and uppercase letters.

In the script we originally created in Chapter 9, Error Checking and Handling, we had the following instructions:

reader@ubuntu:~/scripts/chapter_09$ cat <SNIPPED>read -p "Do you like this question? " reply_variable# See if the user responded positively.if [[ ${reply_variable,,} = 'y' || ${reply_variable,,} = 'yes' ]]; then  echo "Great, I worked really hard on it!"  exit 0fi# Maybe the user responded negatively?if [[ ${reply_variable^^} = 'N' || ${reply_variable^^} = 'NO' ]]; then  echo "You did not? But I worked so hard on it!" exit ...

Get Learn Linux Shell Scripting - Fundamentals of Bash 4.4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.