要求检索的目录是(例如):/data/;数据量:100G左右,z
我的脚本有两个:第一个
#!/bin/bash
#关键字是utf-8对应的base64编码,再在脚本中由base64转utf-8和gbk(如下)
mkeyword=$1
echo $1 | base64 -di > $$_findword.list
echo -ne "\n" >> $$_findword.list
echo $1 | base64 -di |iconv -f utf-8 -t gb2312 >> $$_findword.list
#查询过程
find $fdir -name *.txt -exec fgrep -f $$_findword.list {} -rIbH \; | while read txt; do
mdata=`echo $txt | cut -d ' ' -f 1`
mfile=`echo $mdata | cut -d ':' -f 1` `
mfile=`basename $mfile`
mpos=`echo $mdata | cut -d ':' -f 2`
echo "insert into findres(**) values (**);" >> $$_findres.sql
done
find $fdir -name *.zip -type f | while read zipfile; do
zipdir=`echo $zipfile | cut -d '.' -f 1`
unzip -o $zipfile -d $zipdir rm $zipfile -f done
find $fdir -name *.gz -type f -execdir gzip -df {} \;
find $fdir -name *.gz -exec rm -f {} \;
find $fdir -name "[1|3]_*" -type d -exec fgrep -f $$_findword.list {} -rIo -m 1 \; | grep $fdir | while read line; do
*
echo "insert into findres(**) values (**);" >> $$_findres.sql
done
有没有好点的方法呐?求指点
我的脚本有两个:第一个
#!/bin/bash
#关键字是utf-8对应的base64编码,再在脚本中由base64转utf-8和gbk(如下)
mkeyword=$1
echo $1 | base64 -di > $$_findword.list
echo -ne "\n" >> $$_findword.list
echo $1 | base64 -di |iconv -f utf-8 -t gb2312 >> $$_findword.list
#查询过程
find $fdir -name *.txt -exec fgrep -f $$_findword.list {} -rIbH \; | while read txt; do
mdata=`echo $txt | cut -d ' ' -f 1`
mfile=`echo $mdata | cut -d ':' -f 1` `
mfile=`basename $mfile`
mpos=`echo $mdata | cut -d ':' -f 2`
echo "insert into findres(**) values (**);" >> $$_findres.sql
done
find $fdir -name *.zip -type f | while read zipfile; do
zipdir=`echo $zipfile | cut -d '.' -f 1`
unzip -o $zipfile -d $zipdir rm $zipfile -f done
find $fdir -name *.gz -type f -execdir gzip -df {} \;
find $fdir -name *.gz -exec rm -f {} \;
find $fdir -name "[1|3]_*" -type d -exec fgrep -f $$_findword.list {} -rIo -m 1 \; | grep $fdir | while read line; do
*
echo "insert into findres(**) values (**);" >> $$_findres.sql
done
有没有好点的方法呐?求指点



