Vertical bars in the Linux Shell (|)--Pipe symbols

Source: Internet
Author: User
Pipe symbol, UNIX is a very powerful feature, the symbol is a vertical line: "|".
Usage: Command 1 | Command 2 His function is to pass the result of the first command 1 execution as input of the Command2 to command 2, for example: $ls-S|SORT-NR (Note that you do not copy the $ sign in.)
-S is the file size,-n is Numeric-sort,-r is reverse, reverses the command lists the document in the current directory (with size), and sends the output to the sort command as input, the sort command sorts the output of LS in descending order of numbers.

Output in order from small to large.
Of course, you can also do several operations, such as the following function to remove the pure number, and then by SED to the vertical bar (here is not the pipe symbol) replaced by a space, then the results are taken out to sort, and then the results of the selection display, do not understand the sorting and paging can be seen.

Cat filename |grep-v ' ^[0-9]*$ ' | Sed ' s/|//g ' |sort-nrk 8-nrk9 |tail-n +1 |head-n 10

Vertical bars in the Linux Shell (|)--Pipe symbols

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: 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.