Bird
0
0

Which option correctly uses cut to extract the first 3 characters of each line from a file named data.txt?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Text Processing in Scripts
Which option correctly uses cut to extract the first 3 characters of each line from a file named data.txt?
Acut -c 1-3 data.txt
Bcut -f 1-3 data.txt
Ccut -d 1-3 data.txt
Dcut -l 1-3 data.txt
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct option for character extraction

    The -c option extracts characters by position, so cut -c 1-3 extracts first 3 characters.
  2. Step 2: Understand other options

    -f extracts fields, -d sets delimiter, and -l is invalid for cut.
  3. Final Answer:

    cut -c 1-3 data.txt -> Option A
  4. Quick Check:

    cut character extraction = -c [OK]
Quick Trick: Use -c for characters, -f for fields in cut [OK]
Common Mistakes:
MISTAKES
  • Using -f instead of -c for characters
  • Confusing delimiter option -d
  • Using invalid -l option

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes