Introduction
Changing text to uppercase or lowercase helps make data consistent and easier to read or compare.
variable=${variable^^} # Convert to uppercase
variable=${variable,,} # Convert to lowercasename="hello"
echo ${name^^}name="WORLD"
echo ${name,,}text="Bash Scripting"
echo ${text^^}
echo ${text,,}#!/bin/bash input="Hello Bash" # Convert to uppercase upper=${input^^} # Convert to lowercase lower=${input,,} # Print results echo "Original: $input" echo "Uppercase: $upper" echo "Lowercase: $lower"
name to all uppercase letters?${variable^^} to convert all letters in variable to uppercase.${name^^} uses ${name^^}, which is the correct bash syntax. Using ${name,,} converts to lowercase, and options C and D are not valid bash syntax.text to lowercase in bash?${variable,,}.echo ${text,,} uses ${text,,} which converts all letters to lowercase. echo ${text^^} converts to uppercase, C and D convert only the first letter.word="HelloWorld"
echo ${word,,}word contains "HelloWorld". The expression ${word,,} converts all letters to lowercase.input to uppercase, but it does not work as expected:input="bashScript" echo $input^^
${input^^}.$input^^ without braces, which is invalid syntax and will not convert case.files=("Report1.txt" "summary2.TXT" "DATA3.Txt"). You want to convert all filenames to lowercase and print them line by line. Which script correctly does this?"${files[@]}" correctly accesses each element.${f,,} to convert to lowercase and iterates correctly. for f in "${files[@]}"; do echo ${f^^}; done converts to uppercase, C iterates incorrectly (missing quotes and array expansion), D uses a non-bash function tolower().Pass the test and this pattern moves unknown