Bird
0
0

You wrote this command to extract the first column from a CSV file:

medium📝 Debug Q14 of 15
Bash Scripting - File Operations in Scripts
You wrote this command to extract the first column from a CSV file:
cut -f1 -d',' file.csv
But it returns the whole line instead of just the first column. What is the likely problem?
AThe <code>-f1</code> option is invalid
BThe file is empty
CThe delimiter option <code>-d','</code> is missing or incorrect
Dcut cannot process CSV files
Step-by-Step Solution
Solution:
  1. Step 1: Check the delimiter option usage

    The command uses -d',', which is incorrect. The single quotes make the delimiter the string ',' (quote comma quote) instead of plain comma (,). cut searches for ',' which isn't in the CSV.
  2. Step 2: Understand cut behavior without correct delimiter

    Without splitting on ,, cut falls back to default (TAB), treating each line as one field, so -f1 outputs the entire line.
  3. Final Answer:

    The delimiter option -d',' is missing or incorrect -> Option C
  4. Quick Check:

    cut needs -d, (no quotes around comma) to split fields [OK]
Quick Trick: Always specify -d, for CSV files with cut [OK]
Common Mistakes:
MISTAKES
  • Forgetting -d option
  • Using wrong delimiter character
  • Assuming cut auto-detects delimiter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes