0
0
Bash Scriptingscripting~10 mins

Temporary files (mktemp) 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 create a temporary file using mktemp.

Bash Scripting
tempfile=[1]
Drag options to blanks, or click blank then click option'
Atempfile
Bmktemp
Ctouch tempfile
Drm tempfile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'touch tempfile' creates a file but not a unique temporary file.
Assigning a variable without a command does not create a file.
2fill in blank
medium

Complete the code to create a temporary directory using mktemp.

Bash Scripting
tempdir=[1] -d
Drag options to blanks, or click blank then click option'
Amktemp
Bmkdir
Crm
Dtouch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mkdir' alone does not create a unique temporary directory.
Using 'touch' creates files, not directories.
3fill in blank
hard

Fix the error in the code to safely create a temporary file and write 'Hello' into it.

Bash Scripting
tempfile=[1]
echo "Hello" > $tempfile
Drag options to blanks, or click blank then click option'
Amkdir
Btouch
Crm tempfile
Dmktemp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'touch' does not guarantee a unique filename.
Using 'mkdir' creates a directory, not a file.
4fill in blank
hard

Fill both blanks to create a temporary file with a custom prefix and then remove it.

Bash Scripting
tempfile=[1] -t [2]
rm $tempfile
Drag options to blanks, or click blank then click option'
Amktemp
Btemp
Cmytemp
Dtouch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'touch' does not create a unique temporary file.
Using wrong prefix names or missing the prefix option.
5fill in blank
hard

Fill all three blanks to create a temporary directory with a prefix, list its contents, and then remove it.

Bash Scripting
tempdir=[1] -d -t [2]
ls [3]
rm -r $tempdir
Drag options to blanks, or click blank then click option'
Amktemp
B$tempdir
Dtempdir
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rm' without '-r' to remove a directory causes an error.
Not using the variable to refer to the directory in commands.