Chapter 6 of linuxshell programming guide ------ in-depth discussion ((

Source: Internet
Author: User
We have encountered the & lt; application several times when introducing standard input, standard output, and while loop. We learned how to send emails and create a menu. However, & lt; there are many other Usage cases. This chapter introduces the following :? Quickly create a file .?

We have encountered several times when introducing standard input, standard output, and while loop < <的应用。我们学会了如何发送邮件,如何构建一个菜单,不过< <还有很多其他的用法。< p>

This chapter introduces the following:

Quickly create a file.

The menu is automatically displayed.

Ftp transmission.

Connect to other application systems.

The command is generally in the following format:
Command < T e x t
W o r d

Here is a brief review < <的用法。当shell看到< <的时候,它就会知道下一个词是一个分界符。在该分界符以后的内容都被当作输入,直到shell又看到该分界符(位于单独的一行)。这个分界符可以是你所定义的任何字符串。< p>

Available < <来创建文件、显示文件列表、排序文件列表以及创建屏幕输入。< p>

You can use this method to quickly create a file and save some text to it:
$ Cat> myfile <

Now you can enter some text. at the end, you only need to type NEWFILE in a new line. in this way, a file named yfile is created, which contains some text.

If an existing file is opened, the input content is appended to the end of the file.

If you use the tab key, note that some older shell versions may not understand its meaning correctly. To solve this problem, you can <之后加一个横杠-,就像下面这样:
Cat> myfile <-NEWFILE
[Root @ localhost huangcd] # cat> myfilexx < > Nihao
> Huang chengdu
> Newfile
[Root @ localhost huangcd] # cat newfile
Cat: newfile: the file or directory does not exist.
[Root @ localhost huangcd] # cat myfilexx
Nihao
Huang chengdu

From the menu, if you want to back up all the databases, type:
1) Name of the menu script, sybbackup.
2) Type 2.
3) type 3.
4) type Y.

The following script automatically runs the database backup script sybbackup:

Let's analyze this part. the full path of the script sybbackup is provided here. >>$ log_f 2> & 1 means that all the output is redirected to $ logf, the value of this variable is/logs/SQL. backup. log. This is a good habit, because it can capture all the output of the running program or script and be recorded if an error occurs. <

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.