• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

cut: command not found

by admin

The cut command extracts the specified lines of text from a file. Common cut command options and their uses are given in the following table.

Option Description
-c Specify the number of the character to cut from each line.
-d{delimiter} Separate one field from another.
-f{field numbers} Specify the field numbers to cut on as separated by the delimiter. For example, -f2 indicates the field between the first and second instances of the delimiter.
-s Suppress a line if the delimiter is not found.

Syntax

The syntax of the cut command is:

# cut [options] {file names}

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

If you encounter the below error while running the cut command:

cut: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

cut Command Examples

1. Print a specific character/field range of each line:

# command | cut --characters|fields=1|1,10|1-10|1-|-10

2. Print a range of each line with a specific delimiter:

# command | cut --delimiter="," --characters=1

3. Print a range of each line of the specific file:

# cut --characters=1 path/to/file

4. 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

5. The following command line display only the first four characters of every line in the /etc/passwd file:

$ cut -c 1-4 /etc/passwd

Filed Under: Linux

Some more articles you might also be interested in …

  1. gnome-software: command not found
  2. How to Configure Interface(s) in promiscuous mode on CentOS/RHEL 7 (persistently)
  3. “shutdown” Command Examples in Linux
  4. maim Command Examples in Linux
  5. groupadd: command not found
  6. envsubst: command not found
  7. create_ap Command Examples in Linux
  8. arp: command not found
  9. Rsyslog : How to Send log files to remote server in CentOS/RHEL 6,7
  10. How to change the Default Log Directory(/var/log) in Rsyslog for CentOS/RHEL 6,7

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright