"Linxu learning 007" Pipeline and redirection

Source: Internet
Author: User

First, the pipeline

The use of pipelines makes it easy to implement the output of one program as input to another program. Pipe symbol for ' | ', usage:

Commend | Commend | commend| ......

Example:

[Email protected]:~$ echo "ABCDEFG" | TR [: Lower:] [: Upper:]abcdefg[email protected]:~$ more/etc/passwd | grep ' Kdyzm ' kdyzm:x:1000:1000:kdyzm,,,:/home/kdyzm:/bin/bash[email protected]:~$
Second, redirect

Online Documentation: HTTP://PUBS.OPENGROUP.ORG/ONLINEPUBS/9699919799/UTILITIES/V3_CHAP02.HTML#TAG_18_07

1. Input and output description
English name    Chinese name    file descriptor stdin     standard input         0STDOUT    standard output         1STDERR    standard error Output      2
2. Input redirection
<     : input redirection (redirecting input) <<    : Document here (here-document)

(1). Enter redirection

[Email protected]:~$ tr [: Lower:] [: Upper:] </etc/passwd

(2). Documentation here

[Email protected]:~$ tr [: Lower:] [: Upper:] << eof> nihao> hello> world> eofnihaohelloworld[email prote cted]:~$
3. Output redirection
>        : Overwrite output redirection >>       : Append output redirect &>: Redirect       error output and standard output to the same file 2>       : Error output redirect (overwrite) 2>>      : Error output redirect (append) |>       : Overwrite output redirection is still allowed with SET-C set

Description

Overwrite output redirection is allowed by default, but there is a clear security issue, so you can use the switch to control

Set-c    : When using output redirection, overwrite output redirection (>) set +C is not allowed if the file already exists    : Turn off the function above

If you also want to use overwrite output redirection if SET-C is set, then use |>.

4. How do I save the output to a file while it is displayed on the screen?
Tee

Example:

Tee/tmp/temp.txt


This article is from the "stolen A Plum blog" blog, please be sure to keep this source http://kdyzm.blog.51cto.com/8316029/1740150

"Linxu learning 007" Pipeline and redirection

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.