我正在尝试匹配文件列表中的电子邮件地址,下面是我创建的脚本
#!/bin/bash
for varFile in `ls /var/mail/vhosts/penguin.com/kolosky/cur`;
do
grep "kolosky@penguin.com" $varFile;
if [ $? -eq 0 ];
then
echo $i > /tmp/match.txt;
fi
done
/var/mail/vhosts/penguin.com/kolosky/cur
中的文件如下所示(50K +文件)
1501303677.VdeI4b4601fM34360.vps47619.domain.local:2,
1501327088.VdeI4b46274M887245.vps47619.domain.local:2,
1501350893.VdeI4b46676M714819.vps47619.domain.local:2,
1501351810.VdeI4b466dcM483006.vps47619.domain.local:2,
1501352354.VdeI4b466f6M691159.vps47619.domain.local:2,
1501355883.VdeI4b4675bM598246.vps47619.domain.local:2,
1501360533.VdeI4b4678fM767116.vps47619.domain.local:2,
1501362598.VdeI4b467c2M944374.vps47619.domain.local:2,S
1501366933.VdeI4b46827M6394.vps47619.domain.local:2,
1501371004.VdeI4b468b3M654492.vps47619.domain.local:2,
1501381688.VdeI4b470aaM394586.vps47619.domain.local:2,
1501383441.VdeI4b471dcM297322.vps47619.domain.local:2,
1501385824.VdeI4b4723fM284699.vps47619.domain.local:2,
1501386623.VdeI4b47247M170748.vps47619.domain.local:2,
但这让我失误
grep: 1502103891.VdeI4b56e59M181359.vps47619.domain.local:2,: No such file or directory
grep: 1502103891.VdeI4b56e5aM235352.vps47619.domain.local:2,: No such file or directory
grep: 1502103891.VdeI4b56e5bM258839.vps47619.domain.local:2,: No such file or directory
grep: 1502103891.VdeI4b56e5cM390465.vps47619.domain.local:2,: No such file or directory
grep: 1502103891.VdeI4b56e5dM439473.vps47619.domain.local:2,: No such file or directory
grep: 1502103891.VdeI4b56e5eM479629.vps47619.domain.local:2,: No such file or directory
我尝试将脚本修改为ls /var/mail/vhosts/mailservice935.com/info/cur | sed 's/:/\\:/g' | sed 's/,/\\,/g'
以逃避“:”和“,”但它给出了同样的错误