Top community members
All Wiki Articles Create Wiki Article

In the past we had a dream,
to have place where we could share IT knowledge,
to ask questions without fear that someone will judge us.

Now we are a group of people who make this dream come true. ❤ 💻

If you think sharing knowledge and helping other is valuable.

join our community - Click here

Bash - cut examples

0 contributions
8 points

Using cat method we are able to split rows to columns and select some of them.

1. Opening passwd file and cutting first column by colon delimiter:

$ cut -d ':' -f 1 /etc/passwd

Note: columns counting from 1.

2. Example 1st with output redirection:

cat /etc/passwd | cut -d ':' -f 1

3. It is possible to select columns (1st and 2nd):

cat /etc/passwd | cut -d ':' -f 1,2

4. We can select column range (from 1st to 3rd):

cat /etc/passwd | cut -d ':' -f 1-3

5. We can select column range (from beginning to 3rd):

cat /etc/passwd | cut -d ':' -f -3

6. We can select column range (from 2nd to end):

cat /etc/passwd | cut -d ':' -f 2-

7. We can precise that we want to interpret only characters:

cut -c 2-7 /etc/passwd
cut -c -7 /etc/passwd
cut -c 2- /etc/passwd

 8. We can precise that we want to interpret bytes:

cut -b -10 /etc/passwd


0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more