我有一些脚本,在不同的领域有很多的电子邮件地址(比如domain1.com
,domain2.com
。我想在一些通用的电子邮件地址,以取代所有的人一个普通的域名,说domain.com
,保持其余的脚本相同如何与普通的电子邮件地址替换所有电子邮件地址中的一组文件
我在sed
下面使用,但它似乎并没有工作(它返回相同的输出作为输入,所以看起来像搜索不匹配但是,当我在在线测试中测试正则表达式\[email protected]\S+/
时,它似乎与电子邮件地址匹配。)
s/\[email protected]\S+/[email protected]/g
例如,我有2个脚本
$ cat script1.sh
[email protected]
export SENDFROM="[email protected]" blah_4
$ cat script2.sh
echo foo|mailx -s "blah" [email protected],[email protected],[email protected]
[email protected]
foo [email protected] bar
sed -i
后,我的结果应该是
$ cat script1.sh
[email protected]
export SENDFROM="[email protected]" blah_4
$ cat script2.sh
echo foo|mailx -s "blah" [email protected],[email protected],[email protected]
[email protected]
foo [email protected] bar
我使用Linux 3.10.0-327.28.2.el7.x86_64
任何建议吗?
更新: 我设法使其与's/\S\[email protected]\S\+.com/[email protected]/g'
工作。有2问题与以前search
。
- 该
+
需要\
之前。 - 作为文件有其他
@
线(用于 数据库连接),我不得不在最后追加.com
,因为我所有的 地址在.com
有什么不适用于它? –
对不起。忘了提及。它返回与输入相同的输出。用相同的输入编辑问题。 – Utsav