Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print a message that automation saves time.
Bash Scripting
echo "Automation [1] time and effort."
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing words that mean the opposite of saving time, like 'wastes'.
✗ Incorrect
The word 'saves' correctly completes the sentence to explain that automation helps save time and effort.
2fill in blank
mediumComplete the script to check if a file exists before backing it up.
Bash Scripting
if [[ -[1] "backup.txt" ]]; then cp backup.txt backup.bak fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-d' which checks for directories instead of files.
✗ Incorrect
The '-f' option checks if 'backup.txt' is a regular file, which is needed before copying it.
3fill in blank
hardFix the error in the script that lists all running processes containing 'ssh'.
Bash Scripting
ps aux | grep [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not excluding the grep process, so it appears in the output.
✗ Incorrect
Using 'grep -v grep' removes the grep process itself from the results, showing only actual 'ssh' processes.
4fill in blank
hardFill both blanks to create a loop that prints numbers 1 to 5.
Bash Scripting
for i in [1]; do echo [2] done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' instead of '$i' to print the variable value.
✗ Incorrect
The loop iterates over the list '1 2 3 4 5' and prints each number using '$i'.
5fill in blank
hardFill all three blanks to create a script that counts files in a directory and prints the count if more than 3.
Bash Scripting
count=$(ls [1] | wc -l) if [[ [2] [3] 3 ]]; then echo "There are $count files." fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator like '-lt' instead of '-gt'.
✗ Incorrect
The script counts files in /tmp, then checks if count is greater than 3 to print the message.