1
in folder 
asdasdasd.msg
asdasd.msg
twadasf.msg
...
...
...

*.msg 文件示例电子邮件内容 =>

Date: Wed, 03 Aug 2011 11:20:59 +0300 (EEST)
From: Email Account Name =?utf-8?B?R8OcTkRPxJ5EVQ==?= <emailname@sample.com>
To: Different Email Account Name  <different@sample.com>
Subject: Re: Web Anketi
Message-ID: <d6d75689-bfde-451d-8a91-0da4d4e8921e@posta.sample.com>
In-Reply-To: <4ac9813a-4511-4530-b098-62fd23ecdb5b@posta.sample.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Originating-IP: [10.199.16.77]
....

run.sh 脚本:

    for line in `sed 's/\(<\)\(.*\)\(@sample.com>\)/\2/'` *.msg
    do 
        echo $line
    done

*我的问题是获取电子邮件地址列表 *@sample.com?

获取所有电子邮件地址数组列表?*
4

2 回答 2

0

谢啦 :)

是工作代码

for file in *.msg
do 
    sed -n 's/^.*\(<\)\(.*\)\(@posta.sample.com>\)/\2/p' $file
done

如何定义 ArrayList 变量?

于 2013-08-17T11:53:36.590 回答
0

使用 bash for 循环读取所有 *.msg 文件。sed -n抑制模式的所有不匹配的输出。psed 命令末尾的标志打印出替换的文本。

for file in *.msg
do 
    sed -n 's/^.*\(<\)\(.*\)\(@posta.sample.com>\)/\2/p' $file
done
于 2013-08-16T09:29:15.373 回答