for循环在3次循环后停止

时间:2014-04-01 11:06:14

标签: bash shell for-loop

我的脚本有效。它将mailq中的前三个邮件ID保存在临时文件中,但之后我只收到错误。

for QID in $(/opt/zimbra/postfix/sbin/mailq | grep -E "^[0-9A-F]{10,12}\ "|cut -f1 -d' '); do
    /opt/zimbra/postfix/sbin/postcat -c /opt/zimbra/postfix/conf -q ${QID}|grep -q '$1' &&
    TEMP=`(mktemp /tmp/$1.XXXX)`
    echo ${QID} >> $TEMP
done

echo "All mail in quene from IP $1 is listed in file: $TEMP"

./test.sh 127.0.0.1

./test.sh: line 1: $TEMP: ambiguous redirect

./test.sh: line 1: $TEMP: ambiguous redirect

./test.sh: line 1: $TEMP: ambiguous redirect

./test.sh: line 1: $TEMP: ambiguous redirect

./test.sh: line 1: $TEMP: ambiguous redirect

./test.sh: line 1: $TEMP: ambiguous redirect

来自IP 127.0.0.1的队列中的所有邮件都列在文件:/tmp/127.0.0.1.s7oN

0 个答案:

没有答案