我做了一個腳本,應該修改它看起來像這樣的事情文件的變量的值:修改線的一部分
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = triton.itinet.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = triton, localhost.localdomain, localhost
relayhost = smtp.free.fr
home_mailbox = Maildir/
virtual_mailbox_domains = $myhostname
virtual_mailbox_base = /var/mail/
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
#virtual_alias_maps = hash:/etc/postfix/virtual
我想修改的值用戶進入中繼主機,我已經做到了這一點
modify_relayhost()
{
read new_relayhost
if (test -e /etc/postfix/main.cf)
then
grep "relayhost" /etc/postfix/main.cf | cut -d= -f1 && echo $new_relayhost
fi
}
但它不修改文件,它只是打印我說值稱爲中繼主機和寫入用戶的一個上的提示
這可以幫助你:http://stackoverflow.com/questions/11145270/bash-replace-an-entire-line-in-a-text-file – OscarAkaElvis