0
0
Bash Scriptingscripting~10 mins

Why sysadmin scripts automate operations in Bash Scripting - Test Your Understanding

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

Complete 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'
Asaves
Bwastes
Cignores
Dadds
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing words that mean the opposite of saving time, like 'wastes'.
2fill in blank
medium

Complete 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'
Ae
Bd
Cf
Ds
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-d' which checks for directories instead of files.
3fill in blank
hard

Fix 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'
A'ssh'
B'ssh' | grep -v grep
C"ssh"
Dssh
Attempts:
3 left
💡 Hint
Common Mistakes
Not excluding the grep process, so it appears in the output.
4fill in blank
hard

Fill 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'
A1 2 3 4 5
Bi
C$i
Dseq 5
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' instead of '$i' to print the variable value.
5fill in blank
hard

Fill 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'
A/tmp
B$count
C-gt
D-lt
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator like '-lt' instead of '-gt'.