Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the current directory path.
Bash Scripting
echo [1] Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
The pwd command prints the current directory path in Bash.
2fill in blank
mediumComplete the code to create a new directory named 'backup'.
Bash Scripting
[1] backup Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rm' which deletes files or directories.
Using 'touch' which creates empty files.
✗ Incorrect
The mkdir command creates a new directory in Bash.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The -a option with ls shows all files, including hidden ones starting with a dot.
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 '1..5' which is not a valid list in Bash for loop.
Printing the wrong variable name.
✗ Incorrect
The loop iterates over the list '1 2 3 4 5' and prints each number stored in variable i.
5fill in blank
hardFill 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'
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.
✗ Incorrect
The -e option checks if the file exists. The filename is 'myfile.txt'. The message uses 'does' to say the file exists.