Filter text

The cut command is used for text-filtering. It can be used to print selected parts of lines from a file. For example, to print the third character from the left in the results.txt file, you can use the cut command with the -c option:

linux cut command

To print a range of characters from each line in the results.txt file, you need to specify the start and end positions:

linux cut command range

We can also use the -f option to cut the specified list of fields from the results.txt file. By default, a field is a tab-delimited section of a line, but you can change the delimiting character with the -d CHAR option. For example, we can change the delimiting character to / and use the -f option to display only the third field from each line in the results.txt file:

linux cut command fields

Geek University 2022