!/bin/bash
if [ $# = 0 ];then
echo -e "搜索小脚本 "
echo -e "用法1 搜索文件 :格式 serch [待搜索文件名] "
echo -e “用法2 搜索字符串 : 格式 serch [搜索字符串] [搜索文件类型(all为所有类型)]”
elif [ $# = 1 ];then
find * | grep -Ii “$1” --color=auto
elif [ $# = 2 ];then
if [ $2 != “all” ];then
grep -iIsrn --include=*.$2 “$1” . --binary-files=without-match --color=auto
else
grep -iIsrn “$1” . --binary-files=without-match --color=auto
fi
else
echo “params err !”
fi