Bird
0
0

The following bash script is intended to convert input to uppercase, but it does not work as expected:

medium📝 Debug Q14 of 15
Bash Scripting - String Operations
The following bash script is intended to convert input to uppercase, but it does not work as expected:
input="bashScript"
echo $input^^

What is the error?
AVariable name is incorrect
BMissing braces around the variable for case conversion
CUsing single caret instead of double caret
DUppercase conversion is not supported in bash
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax for uppercase conversion

    Bash requires braces around the variable when using case conversion, like ${input^^}.
  2. Step 2: Analyze the script

    The script uses $input^^ without braces, which is invalid syntax and will not convert case.
  3. Final Answer:

    Missing braces around the variable for case conversion -> Option B
  4. Quick Check:

    Use ${variable^^} with braces for uppercase [OK]
Quick Trick: Always use braces ${} for case conversion in bash [OK]
Common Mistakes:
MISTAKES
  • Omitting braces around variable
  • Using single caret ^ for all letters
  • Assuming bash lacks uppercase conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes