cut
cut is a filter utility which is used to cut out columns or fields from every line of a file. A field is generally separated through a tab character (default delimiter), but it can also be delimited through any other character.
Syntax
cut -c columnlist [ file ... ]
cut -f fieldlist [ -d delim ] [ -s ] [ file ... ]
where list is a comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to denotes ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-c list, the list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-f list, the list following -f is a list of fields supposed to be separated in the file through a delimiter character.
-d delimiter, the character following -d is the field delimiter (-f option only). Default is tab. other characters or Space along with special meaning to the shell must be quoted. A Delimiter can be a multi-byte character.
Practice 1
Let Consider the file names containing the following information
Pat Gaja 22 C++
Tedd Boycott 34 ORVB
Anju Ahuja 25 C++
Hema Malini 27 DBA
Raju Naidu 31 ORVB
Sonu Misra 28 ORVB
The given example displays the usage of the cut command.
# cut -f 2, 4 names
Gaja C++
Boycott ORVB
Ahuja C++
Malini DBA
Naidu ORVB
Misra ORVB
In the given example the second, fourth fields are cut from the file by using the cut command.