0
0
Bash Scriptingscripting~10 mins

Escape characters (\) in Bash Scripting - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print a double quote inside the string.

Bash Scripting
echo "She said, \[1]Hello\[1]"
Drag options to blanks, or click blank then click option'
A\
B'
C"
D$
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of escaping double quotes.
Not escaping the double quotes, causing syntax errors.
2fill in blank
medium

Complete the code to print a newline character using echo.

Bash Scripting
echo -e "First line[1]Second line"
Drag options to blanks, or click blank then click option'
A\n
B\\
C\r
D\t
Attempts:
3 left
💡 Hint
Common Mistakes
Using \t which inserts a tab instead of a newline.
Not using -e option, so escape sequences are not interpreted.
3fill in blank
hard

Fix the error in the code to correctly print a backslash character.

Bash Scripting
echo "This is a backslash: [1]"
Drag options to blanks, or click blank then click option'
A/
B\\
C"
D\
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single backslash which escapes the next character.
Using a forward slash instead of backslash.
4fill in blank
hard

Fill both blanks to print a tab and a newline in the output.

Bash Scripting
echo -e "Column1[1]Column2[2]End"
Drag options to blanks, or click blank then click option'
A\t
B\n
C\r
D\\
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up \r (carriage return) with \n (newline).
Not using -e option so escapes are not processed.
5fill in blank
hard

Fill all three blanks to create a string with a literal dollar sign, a double quote, and a backslash.

Bash Scripting
echo "Price: [1]100, Quote: [2]Hello[2], Path: C:[3]Users"
Drag options to blanks, or click blank then click option'
A\$
B\"
C\\
D\n
Attempts:
3 left
💡 Hint
Common Mistakes
Not escaping the dollar sign causing variable expansion.
Using single backslash for backslash printing.
Not escaping double quotes causing syntax errors.