Difficulty: Easy
Correct Answer: -d option
Explanation:
Introduction / Context:When extracting fields with cut, the utility must know how to split each line. The delimiter can be a comma, tab, colon, or any single character. Choosing and declaring the correct delimiter is essential for accurate column extraction.
Given Data / Assumptions:
Concept / Approach:The -d option to cut sets the field delimiter. For example, -d ',' uses a comma; -d ':' uses a colon. Without -d, cut defaults to tab for field mode. Pair -d with -f to pick specific fields. Other letters shown here (-a, -r, -x) are not valid delimiter switches for cut.
Step-by-Step Solution:
Use comma as delimiter: cut -d ',' -f 2,4 data.csvUse colon for /etc/passwd style: cut -d ':' -f 1,7 /etc/passwdDefault tab delimiter: cut -f 1-3 data.tsvChain with sort/uniq for further processing.Verification / Alternative check:Print a sample line and visually count separators to ensure that the -d character matches the actual data; otherwise you will see empty or misaligned fields in output.
Why Other Options Are Wrong:
Common Pitfalls:Using multi-character delimiters (unsupported by cut) or forgetting to quote special shell characters such as '|' or '*' if used as delimiters in unusual cases.
Final Answer:-d option
Discussion & Comments