Extracting columns with 'cut'

Specific columns can be extracted from a file. For example, if we wanted to extract columns 2, 4, 5, 6 and 8+ from file.csv:

cut -d , -f 2,4-6,8- file.csv

Here, the '-d ,' tells cut that columns are separated by commas, and -f 2,4-6 tells it to extract column 2 and columns 4-6. The -f argument can take a single column number or a comma-separated list of numbers and ranges. It seems to only work if numbers are sequential, so you can't use 'cut' to rearrange columns.

AWK

NR - the current line number

NF - the number of fields (columns) on the line, $NF references the last field