Bird
0
0

Given a file data.txt with contents:

medium📝 Command Output Q4 of 15
Linux CLI - Viewing and Editing Files
Given a file data.txt with contents:
Line1
Line2
Line3
What will be the output of cat -n data.txt?
A1 Line1 2 Line2 3 Line3
BLine1 Line2 Line3
CLine1 1 Line2 2 Line3 3
DError: invalid option
Step-by-Step Solution
Solution:
  1. Step 1: Understand the -n option of cat

    The -n option numbers all output lines.
  2. Step 2: Apply numbering to each line in the file

    Each line is prefixed with its line number and a tab, so output is numbered lines.
  3. Final Answer:

    1 Line1 2 Line2 3 Line3 -> Option A
  4. Quick Check:

    cat -n adds line numbers [OK]
Quick Trick: Use cat -n filename to number lines [OK]
Common Mistakes:
  • Ignoring line numbers
  • Confusing option with line content
  • Expecting numbers after lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes