Special character understanding of Linux (Sixth chapter)

Source: Internet
Author: User
Tags ming

Special symbols:

Input redirection: The output of the previous input into the file in the back, will erase the original contents of the file.
Example:
[Email protected] kang]# echo ' Hello World ' > Test.txt
[email protected] kang]# cat Test.txt
Hello World

> Append output redirection: Append the previous output to the trailing end of the file, without erasing the original contents of the file.
Example:
[email protected] kang]# cat Test.txt
Hello World
Ming Kang

< input redirection: Input redirection is used to change the input of the command, followed by specifying the input, preceded by the file name.
Example:
[Email protected] kang]# Xargs-n 1 < test.txt
Hello
World
Ming
Kang

<< Append input redirection: followed by a string to indicate "input end" or ctrl+d to end the input
[email protected] kang]# cat >>test.txt<<eof

You are welcome
Eof
[email protected] kang]# cat Test.txt
Hello World
Ming Kang
You are welcome

2> Error Redirection: Entering the error message into a file behind it will delete the original contents of the file.
Example:
[[email protected] kang]# Echb ' ERROR ' 2> test.txt
[email protected] kang]# cat Test.txt
-bash:echb:command not found

2>> Error Append redirect: Appends the error message to the file behind it and does not delete the original contents of the file.
[Email protected] kang]# eco ' test ' 2>> test.txt
[email protected] kang]# cat Test.txt
-bash:echb:command not found
-bash:eco:command not found

Enter the correct and incorrect information, respectively, into different file methods:
[Email protected] kang]# echo ' Hello World ' >ok.txt 2>error.txt
[email protected] kang]# cat Ok.txt
Hello World

Put the correct and wrong information, enter the same file:
[[email protected] kang]# ech ' ERROR ' >>ok.txt 2>&1
[email protected] kang]# cat Ok.txt
Hello World
-bash:ech:command not found

Special character understanding of Linux (Sixth chapter)

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.