Ad space (banner)
🖥️Linux Lessons
Lesson 25 / 61

Extracting a Column with cut

cut is for when "I want to pull out one specific column from a CSV file." cut splits each line by a given delimiter and extracts just the specified column (field).

Use it in the form cut -d delimiter -f column-number filename. -d specifies the delimiter, and -f specifies which column number to extract.

Running cut -d , -f 1 data.csv splits each line of data.csv on commas and extracts just the 1st column from every line.

A common early mistake is the delimiter actually being a tab or multiple spaces instead of a comma, so -d is set incorrectly and the split doesn't work right. Check the file's actual delimiter beforehand.

In real work, this is used for lightweight CSV processing — pulling out just one column as material for aggregation or further processing.

Linux
Try it (type this into the pseudo terminal)
cut -d , -f 1 data.csv

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)