0
0
Bash Scriptingscripting~10 mins

Why Bash scripting automates Linux tasks - 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 the current directory path.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
Acd
Bls
Cpwd
Dmkdir
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ls' which lists files instead of showing the path.
Using 'cd' which changes directory but does not print it.
2fill in blank
medium

Complete the code to create a new directory named 'backup'.

Bash Scripting
[1] backup
Drag options to blanks, or click blank then click option'
Amkdir
Bcp
Ctouch
Drm
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rm' which deletes files or directories.
Using 'touch' which creates empty files.
3fill in blank
hard

Fix the error in the script to list all files including hidden ones.

Bash Scripting
ls [1]
Drag options to blanks, or click blank then click option'
A-l
B-a
C-r
D-h
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-l' which shows detailed info but not hidden files.
Using '-r' which reverses order but does not show hidden files.
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
D1..5
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1..5' which is not a valid list in Bash for loop.
Printing the wrong variable name.
5fill in blank
hard

Fill all three blanks to create a script that checks if a file exists and prints a message.

Bash Scripting
if [[ -[1] [2] ]]; then
  echo "File [3] exist."
else
  echo "File does not exist."
fi
Drag options to blanks, or click blank then click option'
Ae
Bmyfile.txt
Cdoes
Df
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-f' which checks if it is a regular file but '-e' is more general.
Forgetting to put the filename in the test.
Using wrong words in the echo message.