Forrest logo
tool overview
On this page you find all important commands for the CLI tool cut. If the command you are looking for is missing please ask our AI.


The "cut" command is a powerful text processing tool available in Unix-like operating systems. It allows you to extract specific portions of lines from files or standard input based on specified delimiters or byte or character positions.

Here are some key features and usage examples of the "cut" command:

  1. Field Extraction: The cut command enables you to extract specific fields or columns from a file. You can define the delimiter (such as space or tab) that separates the fields and mention the field numbers (counting from 1) to extract them.

Example: Suppose you have a file called "data.txt" containing records with fields separated by commas. To extract the second and fourth fields, you can use the following command:

cut -d',' -f2,4 data.txt
  1. Character Extraction: In addition to fields, "cut" also allows you to extract character ranges from each line of a file. You specify the starting and ending positions using the "-c" option.

Example: Consider a file called "text.txt" where you want to extract characters from position 5 to 9 of each line. You can execute the following command:

cut -c5-9 text.txt
  1. Delimiter Manipulation: The "cut" command can split lines using a custom delimiter specified with the "-d" option. It provides flexibility in dealing with files containing different types of delimiters.

Example: Let's say you have a file "users.txt" with fields separated by a semicolon. To extract the usernames, you can use the following command:

cut -d';' -f1 users.txt
  1. Input Sources: "cut" can read input from files or accept standard input. When no file arguments are specified, it reads from the standard input stream. This allows you to pipe the output of other commands to "cut" for further processing.

Example: Suppose you have a command "list_processes" that lists running processes. You can extract only the process names by combining it with "cut" as follows:

list_processes | cut -d' ' -f1

The "cut" command is versatile and offers several options to manipulate and extract specific data from files or pipelines, making it a handy tool for text processing tasks in the command line environment.

List of commands for cut:

  • cut:tldr:13c42 cut: Print a range of each line of the specific file.
    $ cut --${characters}=${1} ${filename}
    try on your machine
    explain this command
  • cut:tldr:ed2cc cut: Print a range of each line of a specific file.
    $ cut -${c} ${1} ${filename}
    try on your machine
    explain this command
tool overview