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