LPIC-1 Shells, Scripting and Data Management Practice Question
Given a file with lines like 'John:23:Engineer', which awk command prints only the name and department (first and third fields) separated by a space?
⚠ Common exam trap
It's easy for candidates to confuse the comma (which inserts the OFS) with concatenation (no comma), leading them to pick options like C or D that produce no space between fields, or they misidentify the field numbers and select B instead of A.
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
✓
awk -F: '{print $1,$3}' file
The `-F:` flag sets the field separator to colon, and `{print $1,$3}` prints the first and third fields separated by the default output field separator (a space). This matches the requirement to output the name and department from lines like 'John:23:Engineer'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
awk -F: '{print $1,$3}' file
Why this is correct
Comma in print outputs space separator.
- ✗
awk -F: '{print $1,$2}' file
Why it's wrong here
Prints name and age (second field).
- ✗
awk -F: '{print $1 $3}' file
Why it's wrong here
Concatenates fields without space.
- ✗
awk -F: '{print $1 $2}' file
Why it's wrong here
Concatenates name and age.
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.