Shell <<eof

Source: Internet
Author: User

1, consider the following requirements, in the main shell execution command, enter the other command, the input after, want to as the input of the command, instead of the main shell input, how to do?

2, use <<eof, tell the main shell, the subsequent input, is the input of other commands or sub-shell, until the encounter EOF, and then back to the main shell.

3. The EOF here is just a delimiter and can be used with other characters.

4, such as cat, do not use EOF, as follows:
[email protected] ~]# cat >111.txt
Abcd
1234

[Email protected] ~]# more 111.txt
Abcd
1234
Using EOF
[email protected] ~]# cat >111.txt<<eof
> AAAA
> bbbb
> EOF
[Email protected] ~]# more 111.txt
Aaaa
bbbb
5, after the installation of MySQL, forget the password, can be used to say the following script, as follows:
/etc/init.d/mysqld stop

Service mysqld Start--skip-grant-tables
Sleep 4
Mysql-hlocalhost << EOF
Update Mysql.user set Password=password (' 123456 ') where user = ' root ';
Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option;
Flush privileges;
Eof

/etc/init.d/mysqld restart

Shell <<eof

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.