cut takes one column from each line. Columns are parts of a line, separated by one character, such as a space or a comma.
08:14column 1anacolumn 2order-1001column 3
text
learner@tidepool:~$ cut -d' ' -f2 visits.log
ana
ben
ana| Flag | Means |
|---|---|
-d' ' | The columns are separated by a space |
-d, | The columns are separated by a comma |
-f2 | Take column 2 |
Put the space in quotes: -d' '. Without quotes, the shell removes the space, as you learned in "Quotes".
In a pipeline
cut gives you one column. Then sort and other commands can work on it:
text
learner@tidepool:~$ cut -d' ' -f2 visits.log | sort
ana
ana
benThe next lesson counts how many times each name is in the list.