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

What are the common text processing commands under Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces what are the commonly used text processing commands under Linux, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.

one。 Sort

File sorting, usually used in pipes as a filter. This command sorts file lines according to the specified keyword or the specified character position. Using the-m option, it will merge the pre-sorted input files. For all the parameters of this command, please refer to the info page of this command.

two。 Tsort

Topological sorting, reading ordered pairs separated by spaces, and sorting depending on the input mode.

three。 Uniq

This filter will remove duplicate lines from a sorted file. This command often appears after the pipe of the sort command.

four。 Expand, unexpand

The expand command will convert each tab to a space. This command is often used in pipes.

The unexpand command will convert each space into a tab. The effect is the opposite of the expand command.

five。 Cut

A tool that extracts a specific domain from a file. This command is similar to the print $N command used in awk, but is more limited. Using the cut command in a script is easier than using the awk command. The most important options are the-d (field delimiter) and-f (field delimiter) options.

six。 Paste

Merge multiple files into one file in the form of one column for each file, and each column in the merged file is the original file. Used in conjunction with cut, it is often used to create system log files.

seven。 Join

This command is similar to the paste command. But it can accomplish some special purposes. This powerful tool can merge two files in a special form that is essentially a simple version of an associated database.

The join command can only manipulate two files. It can combine rows with a specific tag field (usually a numeric label) and output the results to stdout. The added files should be sorted in advance according to the tag field so that they can be matched correctly.

eight。 Head

Print the high-quality content of the file to stdout (the default is 10 lines, which can be modified by yourself). There are some interesting options for this command.

nine。 Tail

Outputs the contents of the end of a file to stdout (10 lines by default). Typically used to track changes to a system logfile, this command will continue to display lines added to the file if the-f option is used.

ten。 Wc

Wc can count the "number of words" in a file or Iram O stream.

eleven。 Fold

Wraps the input at the specified width. Here is a very useful option-s, which can use spaces to break lines (translator: in fact, only foreign languages need to use spaces to break lines, Chinese is not needed) (please refer to examples 12-23 and examples Amur1).

twelve。 Fmt

A simple file formatter. It is usually used in pipelines to "wrap" a long line of text output.

thirteen。 Col

This command is used to filter out the reverse newline symbols of standard input. This tool can also replace whitespace with the equivalent tab. The main application of the col tool is to filter output from specific text processing tools, such as groff and tbl. (translation note: mainly used to convert man pages into text.)

fourteen。 Column

Column formatting tool. By inserting tab in the right place, this filtering tool converts column-type text into an "easy to print" table format for output.

fifteen。 Colrm

Column removes the filter. The tool will delete the specified column (the string in the column) from the file and write it to the file, and if the specified column does not exist, it will go back to stdout. Colrm 2 4

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

Servers

Wechat

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

12
Report