为什么80%的码农都做不了架构师?>>>
两个shell文件,读起来完全一样,但一个能正常运行,另一个则不行。仔细的检测了很久后才发现是EOF后面多空格造成的。
-- eof1.sh
#!/bin/bash
cat >> /home/nobody/shell/eof1.txt <<EOF
abc
abc
EOF
date
[nobody@oc8243606638 shell]$ ./eof1.sh
Thu Jun 13 00:45:06 CST 2013
[nobody@oc8243606638 shell]$ cat eof1.txt
abc
abc
-- eof2.sh
#!/bin/bash
cat >> /home/nobody/shell/eof2.txt <<EOF
abc
abc
EOF
date
# EOF后有空格
[nobody@oc8243606638 shell]$ ./eof2.sh
./eof2.sh: line 9: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
[nobody@oc8243606638 shell]$ cat eof2.txt
abc
abc
EOF
date
# EOF后有空格