Linux Learning notes-how to write content to a file using the echo command

Source: Internet
Author: User
Tags echo command string back

0. PrefaceThis article summarizes how to use the echo command to write content to a file, such as using the ECHO directive to overwrite the contents of a file. Use the echo command to append content to a file. Use the Echo command to append tabs to the file. The basic way for Echo to output content to a file is to use the IO redirect command--">", by default the echo is output to standard output, and the > instruction is used to redirect output to a file.
1.echo Instruction Basic use method"1" Linux official User manual--echo instruction "2" input instructions get help sudo echo--help return content such as the following
How to use: echo [short options] ... [String] ... Or: The Echo long option echoes the STRING back to standard output. -  N does not follow the newline character-  e enable the escape function to interpret backslashes-  e disables the escape function that interprets backslashes (default)      --HELP displays this help information and exits      --version displays the version number information and exits if-e is available, The following sequence can be identified:  \ \    backslash  \a    ring ringtone  \b  \c    no longer produces new output  \e    escape character    \f    Change page  \ n    new line \  r    enter \  t    horizontal tab  \v    vertical tab  \0nnn   bytes in octal number NNN (1 to 3 bits)  \xhh    Bytes in hexadecimal number HH (1 to 2 bits)

2. Overwrite file contentsDemo Sample script test.sh uses the > directive to overwrite the original contents of the file and enter the contents again. Creates a file if the file does not exist. #!/bin/bashecho "Raspberry" > test.txt "Operation Process" # Change permissions, scripts can run chmod u+x test.sh./test.sh "File Contents" Raspberry
3. append file Contents"Demo Sample Script" test.sh

Linux Learning notes-how to write content to a file using the echo command

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