Difficulty: Easy
Correct Answer: cut
Explanation:
Introduction / Context:
Processing delimited text (CSV, TSV, logs) often requires selecting particular fields. Unix pipelines favor small utilities that do one job well. The command that slices columns or character ranges directly from lines is concise and efficient for this purpose.
Given Data / Assumptions:
Concept / Approach:
The cut command extracts selected fields (-f) or character positions (-c) using a specified delimiter (-d). It is ideal for simple, position-based selection. For more complex parsing (quotes, variable delimiters), consider awk, but for straightforward column extraction, cut is the canonical tool.
Step-by-Step Solution:
Verification / Alternative check:
Use head and echo to preview a few lines, then run cut and manually verify fields align with the delimiter you chose. If fields contain the delimiter inside quotes, switch to awk for robustness.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting to set the delimiter with -d, assuming tabs by default when input is comma-separated, or expecting cut to handle quoted CSV intricacies.
Final Answer:
cut
Discussion & Comments