Cut lines in a file using a delimiter and select specific columns

The cut command is extremely powerful. In this example we look at using the cut command to parse a comma separated file and retrieve columns 1 to 4

cut -d "," -f -4
-d specifies the delimiter
-f specifies which columns to select. In this case we select all columns upto 4

The unix pipe command can be used to further work wonders. For example if you want to create unique values from the first column of a comma separated file then all you have to do is

cut -d "," -f 1 | sort | uniq