[root@xml-datacenterGroup01-01 ~]# less test.sh
#!/bin/bash
a=1
su - lvguanjia << ABC
a=2
echo $a $1
ABC
su - lvguanjia << ABC
a=2
echo \$a $1
ABC
su - lvguanjia << "ABC"
a=3
echo $a one:\$1 two:$1
ABC
[root@xml-datacenterGroup01-01 ~]# ./test.sh nihao
1 nihao
2 nihao
#!/bin/bash
a=1
su - lvguanjia << ABC
a=2
echo $a $1
ABC
su - lvguanjia << ABC
a=2
echo \$a $1
ABC
su - lvguanjia << "ABC"
a=3
echo $a one:\$1 two:$1
ABC
[root@xml-datacenterGroup01-01 ~]# ./test.sh nihao
1 nihao
2 nihao
3 one:$1 two:
本文转自 freeterman 51CTO博客,原文链接:http://blog.51cto.com/myunix/1739352,如需转载请自行联系原作者