The cut command is used to display only specific columns or characters from a text file or from other command outputs. For example, in the following command, we display the login names from the /etc/passwd file:
$ cut -d: -f1 /etc/passwd
Output upon execution of the preceding command is shown in the following screenshot:
The following command line displays the first and third fields from a colon-delimited file (extra lines stripped from output):
$ cut -d: -f1,3 /etc/passwd
Output upon execution of the preceding command is shown in the following screenshot:
The following command line display only the first four characters of every line in the /etc/passwd file:
$ cut -c 1-4 /etc/passwd