gpt4 book ai didi

linux - Bash 忽略 $

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:56:52 25 4
gpt4 key购买 nike

我有一个 bash 脚本,它在后缀 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 - Bash 忽略 $,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16355627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com