Bird
0
0

Which of the following is the correct syntax to extract the 3rd character from each line of a file named file.txt?

easy📝 Syntax Q3 of 15
Linux CLI - Text Processing
Which of the following is the correct syntax to extract the 3rd character from each line of a file named file.txt?
Acut -c3file.txt
Bcut -c 3 file.txt
Ccut -d 3 file.txt
Dcut -f 3 file.txt
Step-by-Step Solution
Solution:
  1. Step 1: Understand character extraction syntax

    The -c option extracts characters by position. The correct syntax includes a space before the character number.
  2. Step 2: Validate options

    -f extracts fields, -d sets delimiter, and -c3 without space is invalid syntax.
  3. Final Answer:

    cut -c 3 file.txt -> Option B
  4. Quick Check:

    Extract 3rd char = cut -c 3 [OK]
Quick Trick: Use space after -c to specify character position [OK]
Common Mistakes:
  • Using -f instead of -c for characters
  • Omitting space after -c
  • Using -d to select characters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes