Linux pipeline commands

Source: Internet
Author: User
Tags month name
The pipeline command operator is: & rdquo; | & rdquo;, which can only process the correct output information sent from the previous command, that is, the pipeline command operator of standardoutput is: "|", which can only process the correct output information transmitted through the previous command, that is, the standard output information. for stdandard
Error information is not directly processed. Then, pass it to the next command as the standard input.
Note:
1. pipeline commands only process the correct output of the previous command, without handling the error output
2. the command on the right of the pipeline command must be able to receive standard input stream commands.

To receive standard input commands. Otherwise, data will be discarded during the transfer process. Commonly used to receive data pipeline commands include: sed, awk, cut, head, top, less, more, wc, join, sort, split, and so on. these are all text processing commands.

1. the cut command is used to intercept a string and display it on the standard output. The unit of interception is behavior.
-C, -- characters = LIST: in characters.
-D, -- delimiter = DELIM: delimiter, which is a TAB by default.

-F, -- fields = LIST: in the unit of fields.

2. grepgrep is a text search tool used to find the specified match and output it to the standard output. Regular expressions are supported.
-C, -- count: only the total number of matched rows in the output file
-I, -- ignore-case: case insensitive.
-N, -- line-number: add the row number to the output.

-V, -- invert-match: displays only the rows that do not contain a match.



3. the sortsort command is used to sort the file content and display it to the standard output. Sorting is based on one or more keywords. By default, sort sorts data in the first column.
-B, -- ignore-leading-blanks: ignore the leading space characters and tabs.
-F, -- ignore-case: case insensitive.
-M is sorted by month name.
-N: use pure numbers for sorting
-R reverse sorting
-T delimiter. the default delimiter is Tab.

-K is sorted by a given interval.



4. uniq repeats the result. only one row is displayed for duplicate rows.
-C, -- count: the number of times the row appears in the file at the beginning of each row when the output is displayed.
-D, -- repeated: only duplicate rows are displayed.
-I, -- ignore-case: case insensitive.

-U, -- unique: only show non-duplicate rows in the file.



5. wc collects statistics on the results.
-L only list rows
-W: how many words are listed

-M characters



6. teetee will output the data in the file to the MPs queue.

-A writes data to the file in the way of accumulative (append)



7. tr deletes a string in a piece of information and supports regular expressions.
-D. delete the string.

-S to replace repeated strings



8. col-x replace the tab key with the equivalent space key;

-When B has a backslash in the text, only the character followed by the backslash is retained.

9. join connects the rows with the same specified column in the two files. That is, the corresponding rows are spliced into one row based on a column in the two files.
-I: case insensitive
-T CHAR: Use a specified character as the separator for input and output.
-1 indicates the comparison field of the first file.
-2 indicates the comparison field of the second file.

By default, join is separated by blank characters.


Files processed before using join must be sorted in advance. otherwise, some items in comparison will be ignored.





10. paste links the corresponding lines of the two files.
-D specifies the link separator. the default delimiter is the tab delimiter.

-If the file location is changed to-, the system receives the input from standard input.



11. expand display the tab key by the specified number of spaces

-T specifies the number of spaces



12. split-B splits the file by the specified size.

-L split by number of rows



13. xargsxargs constructs a command line consisting of specified commands, options, and parameters read in sequence from standard input; make sure that the read parameters comply with the constraints specified by the xargs option in terms of length and quantity. Then, xargs calls the command line and waits until the execution is complete.
Parameters read from the standard input must be separated by blank characters (not in quotation marks) or line breaks (not escaped. Strings without double quotation marks and line breaks can be caused by double quotation marks. Strings without single quotes and line breaks can be enclosed by single quotes. Unprovoked characters can be escaped with \ in front.
-0 if the input data contains special characters such as ', \, and space, this parameter indicates that it is a general character.
-E is followed by a genetic string. when xargs reads this string, it stops.
-P will be asked when executing the parameters of each command.
-N: the number of subsequent accesses, that is, the number of parameters required for each command execution.

If no command is followed by xargs, echo is used for output by default.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.