Cut command in Linux (cut by columns)
Your most frequent options are:
- -b number: Prints a vertical list with the number byte (from left to right);
- -c number: Prints a vertical list with the number character (from left to right);
- -d delimiter: Configures the delimiter that separates one column from another. The default is the Tab;
- -f number: Prints column number.
Examples:
To get only user account logins from the /etc/passwd file, using cut. In this case the delimiter will be the “:” and the first column.
To take just the first byte of the /etc/passwd file:
To get group names:
The cut command works just like the awk command. The following example produces the same result as the previous command: