Bird
0
0

You want to create a temporary file with a custom prefix 'logfile.' using mktemp. Which command achieves this?

hard🚀 Application Q8 of 15
Bash Scripting - File Operations in Scripts
You want to create a temporary file with a custom prefix 'logfile.' using mktemp. Which command achieves this?
Amktemp --prefix=logfile
Bmktemp -p logfile
Cmktemp logfile.XXXXXX
Dmktemp -t logfile
Step-by-Step Solution
Solution:
  1. Step 1: Understand mktemp template usage

    To add a prefix, use a template with XXXXXX replaced by random characters, e.g., logfile.XXXXXX.
  2. Step 2: Check other options

    mktemp -p logfile uses -p which sets directory, not prefix. mktemp -t logfile is deprecated and may not work. mktemp --prefix=logfile is invalid syntax.
  3. Final Answer:

    mktemp logfile.XXXXXX -> Option C
  4. Quick Check:

    Use template with XXXXXX for prefix in mktemp [OK]
Quick Trick: Use template with XXXXXX for custom prefix [OK]
Common Mistakes:
MISTAKES
  • Using -p for prefix instead of directory
  • Assuming --prefix option exists
  • Not including XXXXXX in template

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes