Linux and Command-Line Basics

$ echo "2026-10-01,ALU,TT,0.82" | cut -d, -f2,4

Which of the following is the output of the command above, which extracts columns from a comma-separated line?

  1. AALU 0.82
  2. BALU,0.82
  3. 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.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. Which of the following is the output of the sed command above, which replaces characters?
  2. In the session above, which of the following is printed by the last awk?
  3. Which of the following describes the files found when find /data -name "*.log" -mtime +7 -size +100M is run with GNU find?
  4. When stopping a process that has stopped responding, it is recommended to first use "kill <process ID>" and to use "kill -9 <process ID>" only if that does not end it. Which of the following is the reason?
  5. While a long-running ./sim.sh is running in a terminal, you want to use other commands in the same terminal. Which of the following is what happens when you press Ctrl+Z and then run bg?