Got it

Syntax of the cut command

Created: Jul 29, 2022 11:25:27Latest reply: Jul 29, 2022 11:29:41 80 1 1 0 0
  HiCoins as reward: 0 (problem unresolved)

Hello, everyone!

Is there any cut command to cut based on a word?

For example, if I have a string of output, I want to truncate the string before vrm.

887 12648 active vrm-01 rqxxxxxxxxxxx
xxx xxxxx standby vrm-02 reqyyyyyyyyy

I want to get the information as following:

887 12648 active vrm
xxx xxxxx standby vrm

Thanks!

  • x
  • convention:

Featured Answers
olive.zhao
Admin Created Jul 29, 2022 11:29:41

Hello, friend!

You can use the cut command to do it.

olive@bond-pc:~$ cat input.txt
887 12648 active vrm-01 rqxxxxxxxxxxx
xxx xxxxx standby vrm-02 reqyyyyyyyyy
olive@bond-pc:~$ cut -f1 -d- input.txt
887 12648 active vrm
xxx xxxxx standby vrm

Hope this helps!

View more
  • x
  • convention:

All Answers
olive.zhao
olive.zhao Admin Created Jul 29, 2022 11:29:41

Hello, friend!

You can use the cut command to do it.

olive@bond-pc:~$ cat input.txt
887 12648 active vrm-01 rqxxxxxxxxxxx
xxx xxxxx standby vrm-02 reqyyyyyyyyy
olive@bond-pc:~$ cut -f1 -d- input.txt
887 12648 active vrm
xxx xxxxx standby vrm

Hope this helps!

View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.
Information Protection Guide
Thanks for using Huawei Enterprise Support Community! We will help you learn how we collect, use, store and share your personal information and the rights you have in accordance with Privacy Policy and User Agreement.