Bird
0
0

What will be the output of the command cat -n file.txt if file.txt contains:

medium📝 Command Output Q13 of 15
Linux CLI - Viewing and Editing Files
What will be the output of the command cat -n file.txt if file.txt contains:
Hello
World
AHello World
BHello 1 World 2
CError: invalid option
D1 Hello 2 World
Step-by-Step Solution
Solution:
  1. Step 1: Understand the -n option

    The -n option numbers each line of the output when displaying file contents.
  2. Step 2: Apply numbering to each line

    Given the file has two lines: "Hello" and "World", the output will prefix each line with its line number: "1 Hello" and "2 World".
  3. Final Answer:

    1 Hello 2 World -> Option D
  4. Quick Check:

    cat -n adds line numbers [OK]
Quick Trick: Use -n to add line numbers to output [OK]
Common Mistakes:
MISTAKES
  • Ignoring line numbers
  • Placing numbers after text
  • Thinking -n is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes