Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the common command cut in Linux

2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the Linux command cut, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The Linux common command cut command is used to display the text of each line from num1 to num2 from the beginning.

Syntax cut [- bn] [file] cut [- c] [file] cut [- df] [file] instructions:

The cut command cuts bytes, characters, and fields from each line of the file and writes them to standard output.

If you do not specify the File parameter, the cut command reads standard input. One of the-b,-c, or-f flags must be specified.

Parameters:

-b: split in bytes. These byte positions ignore multibyte character boundaries unless the-n flag is also specified.

-c: split on a character basis.

-d: custom delimiter, default to tab.

-f: used with-d to specify which area to display.

-n: unsplit multibyte characters. Used only with the-b flag. If the last byte of a character falls within the range indicated by the List parameter of the-b flag, the character will be written out; otherwise, the character will be excluded

Instance when you execute the who command, you will output something similar to the following:

$who rocrocket: 0 2009-01-08 11:07 rocrocket pts/0 2009-01-08 11:23 (: 0.0) rocrocket pts/1 2009-01-08 14:15 (: 0.0) if we want to extract the third byte of each line, that's it:

$who | cut-b 3 c c and above are all the contents of this article entitled "how to use cut with Linux commands". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report