Bird
0
0

What will be the output of this command?

medium📝 Command Output Q4 of 15
Linux CLI - Searching and Finding
What will be the output of this command?
find /var/log -type f -name '*.log' -exec basename {} \;
APrints the base file names of all .log files in /var/log
BPrints the full path of all .log files in /var/log
CDeletes all .log files in /var/log
DShows an error because basename cannot be used with -exec
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command components

    find searches for files ending with .log in /var/log. -exec basename {} runs basename on each file, printing only the file name.
  2. Step 2: Analyze the output

    The output will be the file names without directory paths.
  3. Final Answer:

    Prints the base file names of all .log files in /var/log -> Option A
  4. Quick Check:

    basename with -exec prints file names = A [OK]
Quick Trick: Use basename with -exec to show file names only [OK]
Common Mistakes:
  • Expecting full paths instead of base names
  • Thinking it deletes files
  • Assuming basename can't be used with -exec

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes