Recall & Review
beginner
What is the purpose of the escape character (\) in bash scripting?
The escape character (\) tells the shell to treat the next character literally, ignoring its special meaning. It helps include special characters in strings or commands.
Click to reveal answer
beginner
How do you include a literal dollar sign ($) in a bash string?
Use the escape character before the dollar sign like this: \$. This prevents the shell from interpreting it as a variable.
Click to reveal answer
intermediate
What does this command print? <br>
echo "Hello\nWorld"It prints: Hello\nWorld (with the \n shown literally) because double quotes allow escape characters but echo does not interpret \n as a newline by default.
Click to reveal answer
intermediate
How do you write a newline character inside a bash string using escape sequences?
Use \n inside a string with the -e option in echo, like:
echo -e "Line1\nLine2" to print on two lines.Click to reveal answer
beginner
Why do you need to escape a backslash (\\) itself in bash?
Because the backslash is the escape character, to print a literal backslash you must escape it with another backslash: \\.
Click to reveal answer
What does the escape character (\) do in bash?
✗ Incorrect
The escape character (\) makes the shell treat the next character literally, ignoring special meanings.
How do you print a literal double quote inside a double-quoted string in bash?
✗ Incorrect
Use \" to escape a double quote inside a double-quoted string.
Which command prints two lines using escape sequences?
✗ Incorrect
The -e option enables interpretation of escape sequences like \n for newline.
How do you write a literal backslash in bash?
✗ Incorrect
You must escape the backslash itself with another backslash to print it literally.
What happens if you do not escape a special character in bash?
✗ Incorrect
Without escaping, special characters are interpreted by the shell according to their function.
Explain how the escape character (\) works in bash scripting and give two examples of its use.
Think about how to include special characters in strings.
You got /3 concepts.
Describe how to print a newline in bash using echo and escape sequences.
Remember echo needs a special option to interpret \n.
You got /3 concepts.