$ cat <<EOF > /tmp/testfile
test
EOF
1st 清空testfile文件
2nd 写入内容

$ cat <<EOF >> /tmp/testfile
test again
EOF
1st 追加testfile文件信息

Referred link:
http://www.acyoo.com/archives/2111.html