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 yes-no-optimized.sh script we originally created in Chapter 9, Error Checking and Handling, we had the following instructions:

reader@ubuntu:~/scripts/chapter_09$ cat yes-no-optimized.sh <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 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.