LPIC-1 Shells, Scripting and Data Management Practice Question
A script reads a CSV file where fields may contain commas within quoted strings. Which approach correctly parses such fields?
⚠ Common exam trap
Test-takers frequently assume simple field-splitting tools like 'cut' or 'read' with IFS=',' can handle CSV, but they fail to account for commas inside quoted strings, which is a classic LPIC-1 data management pitfall.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Using awk or a dedicated tool like csvkit
CSV fields containing commas within quoted strings require a parser that understands CSV quoting rules. Awk can be scripted to handle quoted fields, and dedicated tools like csvkit (e.g., csvcut, csvformat) are designed specifically to parse CSV according to RFC 4180, correctly ignoring commas inside double-quoted strings.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Using 'cut -d',' -f1,2 file'
Why it's wrong here
Cut cannot handle quoted commas.
- ✗
Using 'while IFS= read -r line; do ... done < file' and parsing manually
Why it's wrong here
Manual parsing is error-prone.
- ✗
Using 'while IFS=',' read -r f1 f2; do ... done < file'
Why it's wrong here
Simple read cannot handle commas within quotes.
- ✓
Using awk or a dedicated tool like csvkit
Why this is correct
awk can handle quoted fields with FPAT; csvkit is purpose-built.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 527 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.