cut

Extract specific sections from lines

Usage

      cut -f FIELD FILE
    

Splits each line in FILE by TAB and extracts FIELD

Common Flags

-d, --delimiter=DELIM Use DELIM instead of TAB as the field delimiter-f, --fields=LIST Select only the fields specified in LIST

Examples

Split by a specific delimiter

      cut -d ' ' -f 2 file.txt
    

Splits each line by space and extracts field 2

Extract to the end of line

      cut -f 2- file.txt
    

Extracts field 2 and everything coming after it

Extract from the beginning of line

      cut -f -2 file.txt
    

Extracts from the beginning up to and including field 2

Extract everything between two fields

      cut -f 2-4 file.txt
    

Extracts fields 2 to 4