我有一个bash脚本,echo在postfix main.cf文件中
IPADD=$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
cat << EOG > /etc/postfix/main.cf
# LOCAL PATHNAME INFORMATION
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
# QUEUE AND PROCESS OWNERSHIP
mail_owner = postfix
# SENDING MAIL
myorigin = $mydomain
# RECEIVING MAIL
mydestination = $myhostname localhost.$mydomain localhost $mydomain
# TRUST AND RELAY CONTROL
mynetworks_style = host
smtp_bind_address = $IPADD
inet_interfaces = $IPADD, 127.0.0.1
EOG
问题是运行脚本后,它会从以下位置删除“$mydomain”:
# SENDING MAIL
myorigin = $mydomain
并将“$myhostname”和“$mydomain”从
# RECEIVING MAIL
mydestination = $myhostname localhost.$mydomain localhost $mydomain
我希望$ipadd工作并运行,但希望它忽略$mydomain和$myhostname前面的“$”。
这可能吗?
最佳答案
cat << 'EOG' > /etc/postfix/main.cf
# other stuff
myorigin = $mydomain
# other stuff
EOG
Here Document
关于linux - 重击忽略$,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16355627/