Linux06--shell programming 02 Data Flow redirection and piping

Source: Internet
Author: User

Contains 3 types of data streams:

• Standard input (stdin): code 0, Symbol < or <<; standard output (STDOUT): Code 1, Symbol > or >>; standard error Output (STDERR): Code 2, Symbol 2> or 2>>. •>Default iscoverFile contents, if you want toAppendThen use>>

Entering or outputting data from a specified stream is referred to as data redirection.

Pipeline

• The defining symbol for the piping command is "|" • Pipeline commands will only handle stdout, and stderr will be ignored • Pipeline commands must be able to receive data from the previous command as stdin using the pipeline command the primary purpose of the cut grep sort, WC, uniq Cut command is to decompose the data on the same row with the cut parameter:- D followed by a split character, used with-F, and-F splits a piece of information by the D-based split character, and uses-F to select the paragraph.
echo $PATH | Cut-d:-F 5

The grep command is a conditional fetch of a row whose basic syntax is:

[[Email protected]~]# grep [-ACINV] [--color=auto] ' Find string ' filename-a find the binary file as a text file-C   calculates the number of occurrences of the ' found string '-I Ignore case-N and output line number-V Invert selection

In the last output information, it is removed as long as root, and only the first line is taken.
[[Email protected]~]# Last | grep ' Root ' | Cut-d '-F 1

Sort command ": Sort Uniq WC

The sort command is used to sort the input content

[[Email protected]~] # sort [-fbmnrtuk] [file or sdtin]-f  ignore case difference-----  ignore the first whitespace portion-----the name of the month to sort-R  reverse sort-t  The delimiter-K is sorted by the first number of intervals using the last to fetch the output data only from the Account column and sort last | cut-d  '-F 1 | sort

Uniq command to remove duplicate rows from the result

Uniq [-ic]-i ignores case of different-C to count using last to list accounts, only to take out the account column, to sort out only once | Cut-d '-f1 | Sort |uniq-c

The WC command is used to count words, characters, lines,

-L Line-W character-M characters

Linux06--shell programming 02 Data Flow redirection and piping

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.