Data stream redirection and pipeline commands in Linux

Source: Internet
Author: User
Data stream redirection in Linux and redirect (redirect) names in short for code usage standard input (standardinput) stdin0 & lt ;, use the file data as input for other commands & lt;, and set the string standard output (standardoutp... data stream redirection in Linux and redirect (redirect) names in short for code usage standard input stdin 0 <, use the data of the file as input for other commands <, set the standard output stdout 1> of the string after the input ends, and output the correct data in overwriting mode>, standard error output (stderr 2) is the correct data output standard error output (stderr). overwrite the data output standard error 2>, the accumulate method redirects the wrong data output data streams. you can output the stdout or stderr commands to other File or device. You can also input files or devices as stdin and commands. Execution sequence of multiple commands $? Indicates the command execution result. if the value is 0, the command is successful. The commands on both sides of cmd1; cmd2; semicolons are irrelevant, but cmd1 & cmd2 1 is executed in order. if cmd1 is executed successfully and correctly ($? = 0), then execute Route 22. if cmd1 is finished and it is an error ($? <> 0), then do not execute ipv2cmd1 | cmd2 1 if cmd1 is completed and executed correctly ($? = 0), then do not execute limit 22 if cmd1 is completed and is an error ($? <> 0), then execute ipv2cmd1 & cmd2 | cmd3 1 if cmd1's ($? = 0), then execute route 22 if cmd1's ($? <> 0), execute the cmd3 pipeline command (pipe) cmd1 | stdout of cmd2 cmd1. as the stdin pipeline command of cmd2, only stdout is processed, for stderr, the pipeline command will be ignored. it must be able to accept the data of the previous command and become stdin for further processing. that is to say, cmd2 is a specific pipeline command with limited cut from each line, extract the grep that meets the condition in a row. if there is a qualified part, this row is output. Regular expressions are supported. Sort sorts multiple rows in the file uniq. if multiple rows are repeated, only the rows, words, characters, and bytes in the first wc statistic file are output. tee reads from stdin, and output to stdout and file tr to replace or delete a paragraph of text col tab to convert to multiple spaces, or man page to text join to two rows of the same data in the two files, concatenate a paste row and merge the two rows of the two files into one row, and use tab to split expand to convert tab to space split to split a large file into several small files. you can use cat pieces *> file to restore xargs from stdin, multiple parameters are separated by spaces or line breaks. many other commands do not support pipelines. you can use xargs to provide the parameter minus sign-which indicates stdin or stdout to package the files in/home, the packaged data is output to stdout. The first "-" indicates stdout. After going through the pipeline, extract the package's data from stdin. The second "-" represents the stdinLinux code $ tar-cvf-/home | tar-xvf-
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.