REDIRECT Symbol and Tee command difference

Source: Internet
Author: User

REDIRECT Symbol and Tee command difference


Function Description: Reads the standard input data and outputs its contents to a file.

Syntax: Tee [-ai][--help][--version][file ...]

Note: The tee instruction reads data from a standard input device and outputs its contents to a standard output device while saving it as a file.

Parameters
-A or--append attaches to the back of the existing file rather than overwriting it.
The interrupt signal is ignored by the-i-i or--ignore-interrupts.
--help online Help.
--version Displays version information.


One, redirect
1.1      redirect Symbol
>    output redirected to a file or device Overwrite the original file
>!   output redirects to a file or device to force overwriting the original file
>>              Output redirected to a file or device append the original file
<    input redirected to a program

1.2 standard error false redirect symbol
2>  REDIRECT a standard error output to a file or device overwriting the original file   B-SHELL
2>>  REDIRECT a standard error output to a file or device appended to the original file
2>&1  redirects a standard error output to the standard output Note: 1 may be the representative Standard output
>&    redirects a standard error output to a file or device overwriting the original file   C-SHELL
|&   a standard error pipe to another command as input

1.3 Command Redirection example
1. Standard input, code 0, or stdin; use <                         &NB Sp                          ,         &NB Sp
2. Standard output: Code 1; or stdout; used in 1>
3. Error Output: Code 2, or stderr; used in 2>

[email protected] ~]# who | Tee who.out
Root pts/0 2009-02-17 07:47 (123.123.123.123)
[email protected] ~]# cat Who.out
Root pts/0 2009-02-17 07:47 (123.123.123.123)
[Email protected] ~]# pwd | Tee-a Who.out
/root
[email protected] ~]# cat Who.out
Root pts/0 2009-02-17 07:47 (123.123.123.123)
/root
[Email protected] ~]# echo "I Love You" | Tee 1.txt

I Love You

[Email protected] ~]# echo "I Love You" | Tee-a 1.txt

I Love You

[[Email protected] ~] #cat 1.txt

I Love You

I Love You


[Test @test test]# ls-al > List.txt
Output the displayed results to the List.txt file, and replace the file if it exists!

[test @test test]# ls-al >> list.txt
Add the displayed results to the List.txt file, which is cumulative and the old data is retained!

[test @test test]# ls-al  1> list.txt   2> list.err
data output to List.err

for display data, correct output to list.txt error

[test @test test]# ls-al 1> list.txt 2> &1
Output the displayed data, whether correct or error, to List.txt! Error and correct file output to the same file, it must be written in the method above! cannot be written in any other format!

[Test @test test]# ls-al 1> list.txt 2>/dev/null
The data that is displayed, the correct output to the List.txt error, is discarded! /dev/null, can be said to be a black hole device. is empty, which is not saved.




This article is from the "Little K" blog, make sure to keep this source http://zyp88.blog.51cto.com/1481591/1604036

REDIRECT Symbol and Tee command difference

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.