cut

We can use cut to extract information from a text file. We usually just need to specify the delimited between the fields of data, using the -d option, and we also need to specify the fields to extract, using the -f option. For example, we can display the city and state of the donations to federal election campaigns.

cut -d"|" -f9,10 /anvil/projects/tdm/data/election/itcont2024.txt | head

FIXTHIS we need to check the example above, and probably add a few more examples from some other data sets, using different delimiters, and maybe using a range of fields.

FIXTHIS See section 21.14 of the Unix Power Tools book

If you need to do more sophisticated work with columns, it is helpful to know that awk can do everything that cut can do, as well as many more things. Sometimes it is nice to just have the simplicity of cut, and other times it is necessary to have the power of awk.