Columns with cut

ledger.csv is comma-separated values: one record per line, with fields split by ,. The first line is a header that names the fields: date,member,action,gold.

cut slices columns out of each line:

  • -d, sets the field delimiter to a comma.
  • -f2 keeps the second field, -f2,4 keeps fields two and four, and -f2- keeps everything from two on.
cut -d, -f2 ledger.csv
cut -d, -f2 ledger.csv | sort | uniq -c

Notice member in the count: the header row came along for the ride. grep -v member removes it.

Real world: exports from spreadsheets, databases and cloud consoles are almost always CSV. cut gives you answers in seconds, without opening a spreadsheet.