I/O redirection in Linux

Source: Internet
Author: User

System settings

Default output device: Standard output,stdout,1

Default input device: standard input,stdin,0

Standard error Output:STDERR,2

Standard input: Keyboard

Standard output and Error output: Display

1. Output redirection  

>: Overwrite output

>>: Append output

If you can use set-c to prevent operational errors, the file presence cannot be overwritten function set +c can be closed

You can also use >| When you turn on set-c Force Overwrite

2. Error output Redirection

2> Coverage

2>> Append

3, that is, directional error and correct orientation

ls/varr >/tem/var3.out 2>/tem/err.out

OR

Redirect all outputs

&>

4. Input redirection

<

<<: Here documents usually << end or << EOF with end or EOF As the end prompt

Example: cat << END shows what will be written

Cat >>/tmp/myfile.txt << END Appends content redirection to be written to the /tmp/myfile.txt file

5. Command Pipeline

Enter the result of the previous command as the next command

Command 1 |   command 2 | Command 3 ...

Example:echo "Hello word" | tr ' A-Z ' A-Z '

echo ' Radhat ' | passwd--stdin user1 Change Password

6,tee from the standard input read data from the standard output output data and save to a file copy

Example:echo "Hello World" | tee/tep/hello.out


This article is from the "Mr.zhu-Technology Exchange" blog, please be sure to keep this source http://bjishu.blog.51cto.com/7481301/1699662

I/O redirection in Linux

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.