5 Uses of Cut Commands in Linux

Get parts of a line through cut commands

Yang Zhou
TechToFreedom

--

5 Uses of Cut Commands in Linux
Image from Wallhaven

The cut command, as its name implies, is to cut specific parts of each line of input files and print the results to the standard output.

There are many complex text manipulation tools in Linux, such as awk, grep and sed. But cut is a lightweight utility to help you get what you want quickly.

This article will introduce 5 common usages of the cut command.

Note: The default cut version in Mac OS is not the GNU version. So it doesn’t support some options.

Since the cut is part of the GNU core utilities. You can install it on your Mac OS through the following command:

brew install coreutils

Then, you can use the gcut command which represents the GNU version cut.

1. Basic Usages To Cut Fields

By default, the cut command uses TAB as a delimiter to separate different fields of every single line.

For example, I have a simple file called leaders.txt and the content is as follows:

--

--