[root@promote opt]# vim jiaohu3.sh #!/bin/bashread i <<EOF
Hi
EOFecho$i[root@promote opt]# sh jiaohu3.sh
Hi
1.2.2 通过passwd给用户设置密码
[root@promote opt]# vim jiaohu4.sh #!/bin/bashpasswd jerry <<EOF
this_is_password
this_is_password
EOF
1.3 Here Document 变量设定
1.3.1 变量替换
[root@promote opt]# vim jiaohu5.sh #!/bin/bash
doc_file="2020.txt"
i="company"cat>$doc_file<<EOF
take him from home to $i
EOF[root@promote opt]# cat 2020.txt
take him from home to company
1.3.2 变量设定
[root@promote opt]# vim jiaohu6.sh #!/bin/bash
ivar="Great! Beautyful"
myvar=$(cat<<EOF
This is Line 1.
That are Sun,Moin and Stars.
$ivar
EOF)echo$myvar
~
~
[root@promote opt]# sh jiaohu6.sh
This is Line 1. That are Sun,Moin and Stars. Great! Beautyful
1.3.3 关闭变量替换功能
[root@promote opt]# vim jiaohu7.sh #!/bin/bash cat<<'EOF'## 加单引号关闭变量替换功能
This is line.
$num
EOF
~
[root@promote opt]# sh jiaohu7.sh
This is line.
$num
1.3.4 去除每行之前的TAB字符
[root@promote opt]# vim jiaohu7.sh #!/bin/bashcat<<-'EOF'
This is line.
$num
EOF
~
[root@promote opt]# sh jiaohu7.sh
This is line.
$num