在linux邮件服务器上查找邮件

时间:2018-04-12 09:46:42

标签: linux email server find message

我尝试在其中找到指定字符串的消息并在之后删除该文件。这是我的剧本。我做错了什么?

#!/bin/bash
NAME="СЛОВО"
NAME_KOI=`echo "$NAME" | enca -L ru -x koi8-r`
echo $NAME_KOI
NAME_CP1251=`echo "$NAME" | enca -L ru -x CP1251`
echo $NAME_CP1251
NAME_ISO=`echo "$NAME" | enca -L ru -x ISO-8859-5`
echo $NAME_ISO
NAME_IBM=`echo "$NAME" | enca -L ru -x IBM866`
echo $NAME_IBM

for i in `find -type f` ; do  grep -i -e "$NAME_KOI" -e "$NAME_CP1251" -e "$NAME_ISO" -e "$NAME_IBM" $i ; done

1 个答案:

答案 0 :(得分:0)

所以我自己制作剧本

#!/bin/bash
NAME="слово"
NAME_1LOWER="$NAME"
NAME_1UPPER=`echo "$NAME" | sed 's/.*/\u&/'`
echo "NAME_1LOWER:$NAME_1LOWER"

#koi8-r
NAME_1UPPER_KOI=`echo "$NAME_1UPPER" | enca -L ru -x koi8-r`
NAME_1UPPER_QUOT_KOI=`echo "$NAME_1UPPER" | enca -L ru -x koi8-r | qprint -e`
NAME_1UPPER_BASE64_KOI=`echo -n "$NAME_1UPPER" |enca -L ru -x koi8-r | base64 | sed 's/.\{5\}$//'`

#echo "NAME_1UPPER_KOI:$NAME_1UPPER_KOI"
#echo "NAME_1UPPER_QUOT_KOI:$NAME_1UPPER_QUOT_KOI"

NAME_1LOWER_KOI=`echo "$NAME_1LOWER" | enca -L ru -x koi8-r`
NAME_1LOWER_QUOT_KOI=`echo "$NAME_1LOWER" | enca -L ru -x koi8-r | qprint -e`
NAME_1LOWER_BASE64_KOI=`echo -n "$NAME_1LOWER" |enca -L ru -x koi8-r | base64 | sed 's/.\{5\}$//'`

#echo "$NAME_1LOWER_KOI"
#echo "$NAME_1LOWER_QUOT_KOI"

#CP1251
NAME_1UPPER_CP1251=`echo "$NAME_1UPPER" | enca -L ru -x CP1251`
NAME_1UPPER_QUOT_CP1251=`echo "$NAME_1UPPER" | enca -L ru -x CP1251 | qprint -e`
NAME_1UPPER_BASE64_CP1251=`echo -n "$NAME_1UPPER" |enca -L ru -x CP1251 | base64 | sed 's/.\{5\}$//'`

NAME_1LOWER_CP1251=`echo "$NAME_1LOWER" | enca -L ru -x CP1251`
NAME_1LOWER_QUOT_CP1251=`echo "$NAME_1LOWER" | enca -L ru -x CP1251 | qprint -e`
NAME_1LOWER_BASE64_CP1251=`echo -n "$NAME_1LOWER" |enca -L ru -x CP1251 | base64 | sed 's/.\{5\}$//'`

#ISO-8859-5
NAME_1UPPER_ISO=`echo "$NAME_1UPPER" | enca -L ru -x ISO-8859-5 `
NAME_1UPPER_QUOT_ISO=`echo "$NAME_1UPPER" | enca -L ru -x ISO-8859-5 | qprint -e`
NAME_1UPPER_BASE64_ISO=`echo -n "$NAME_1UPPER" |enca -L ru -x ISO-8859-5  | base64 | sed 's/.\{5\}$//'`

NAME_1LOWER_ISO=`echo "$NAME_1LOWER" | enca -L ru -x ISO-8859-5`
NAME_1LOWER_QUOT_ISO=`echo "$NAME_1LOWER" | enca -L ru -x ISO-8859-5 | qprint -e`
NAME_1LOWER_BASE64_ISO=`echo -n "$NAME_1LOWER" |enca -L ru -x ISO-8859-5  | base64 | sed 's/.\{5\}$//'`

#IBM866
NAME_1UPPER_IBM=`echo "$NAME_1UPPER" | enca -L ru -x IBM866`
NAME_1UPPER_QUOT_IBM=`echo "$NAME_1UPPER" | enca -L ru -x IBM866 | qprint -e`
NAME_1UPPER_BASE64_IBM=`echo -n "$NAME_1UPPER" |enca -L ru -x IBM866 | base64 | sed 's/.\{5\}$//'`

NAME_1LOWER_IBM=`echo "$NAME_1LOWER" | enca -L ru -x IBM866`
NAME_1LOWER_QUOT_IBM=`echo "$NAME_1LOWER" | enca -L ru -x IBM866 | qprint -e`
NAME_1LOWER_BASE64_IBM=`echo -n "$NAME_1LOWER" |enca -L ru -x IBM866 | base64 | sed 's/.\{5\}$//'`

#for i in `find -type f` ; do
grep -r \
-e "$NAME_1UPPER_KOI" -e "$NAME_1UPPER_QUOT_KOI" -e "$NAME_1LOWER_KOI" -e "$NAME_1LOWER_QUOT_KOI" -e "$NAME_1LOWER_BASE64_KOI" \
-e "$NAME_1UPPER_CP1251" -e "$NAME_1UPPER_QUOT_CP1251" -e "$NAME_1LOWER_CP1251" -e "$NAME_1LOWER_QUOT_CP1251" -e "$NAME_1LOWER_BASE64_CP1251" \
-e "$NAME_1UPPER_ISO" -e "$NAME_1UPPER_QUOT_ISO" -e "$NAME_1LOWER_ISO" -e "$NAME_1LOWER_QUOT_ISO" -e "$NAME_1LOWER_BASE64_ISO" \
-e "$NAME_1UPPER_IBM" -e "$NAME_1UPPER_QUOT_IBM" -e "$NAME_1LOWER_IBM" -e "$NAME_1LOWER_QUOT_IBM" -e "$NAME_1LOWER_BASE64_IBM" \
./ | enca -L ru -x UTF-8
# $i ; done