shell的EOF用法

将命令输出的结果给一个循环处理,常用的方式如下:

[root@etch171 guosong]# ls |while read line;do echo $line;done
processlist
top

使用EOF处理:

[root@etch171 guosong]# while read line ;do echo $line;done<<EOF
> `ls .`
> EOF
processlist
top
[root@etch171 guosong]# ls .
processlist  top

对应的需求是啥?将多行处理的结果传递给循环

#!/bin/sh
mysql -uroot -p123456 <<EOF
use test;
select * from testaa while a=10000; ###1000 not usr single quote mark,because a is int 
                                                  # type,only char type need single quote mark.
exit
EOF
原文地址:https://www.cnblogs.com/gsblog/p/3370753.html