Cut last column

How to get the last column using cut

To get the last field in a line using cut is simple, just wrap cut with a pair of rev commands and then extract the first field:

1rev | cut -f1 -d' ' | rev

This works as rev simply reverses the characters of each line, pipe it through cut which extracts the required fields (counting in reverse), and then reverses it again so the content is in the original order.

The only thing you have to remember is that, once reversed, field 1 is actually the last, 2 the one before the last and so on.

Last modified January 21, 2022: add cut (567dfa8)