Linux and Command-Line Basics
$ echo "2026-10-01,ALU,TT,0.82" | cut -d, -f2,4Which of the following is the output of the command above, which extracts columns from a comma-separated line?
- AALU 0.82
- BALU,0.82
- CALU,TT,0.82
Show answer and explanation
Answer: B. ALU,0.82
cut's -d specifies the delimiter and -f the numbers of the fields to extract. With -d, making the comma the delimiter, 2026-10-01 is field 1, ALU field 2, TT field 3 and 0.82 field 4. -f2,4 means fields 2 and 4, so the output is ALU,0.82. The original delimiter is kept between the extracted fields.
- A. cut puts the original delimiter (a comma here) between the extracted fields. It does not replace it with a space.
- B. Correct. Fields 2 and 4 are printed, joined by a comma.
- C. This is the output of "-f2-4", which extracts fields 2 through 4. "2,4" means only fields 2 and 4.