我想在awk中运行sendmail命令,但我收到了以下错误。
awk命令
awk '{ split($0,array,"@"); gsub("\."," ",array[1]); system("sendEmail -f foo@boo.com -t " $1 "-u \"Hello from command\" -m \"Dear\ " array[1] \"-s smtp.boo.com:587 -xu khikho -xp khikho"}' email_list.txt
错误:
syntax error near unexpected token
('`
email_list.txt负责人:
user.1@boo.com
user.2@boo.com
user.3@boo.com
提前谢谢。
答案 0 :(得分:3)
这是一种稍微不同的方法,并不是很难让所有引用都正确(根本不使用awk
,只是bash
的字符串解析功能):
while read address
do
user=${address%%@*}
sendEmail -f foo@boo.com -t ${address} -u "Hello from command" -m "Dear ${user}" \
-s smtp.boo.com:587 -xu khikho -xp khikho
done < email_list.txt