好用的 Search Script

這是由我同事所寫的小 script,還蠻好用的。經過作者同意後放入自己的 Blog 中。本 script 可以在程式碼中進行關鍵字的搜索。因為簡單明瞭,所以就不加以解說了。

附帶廣告他的 Blog: http://parrotshen.blogspot.com/

#!/bin/bash

if [ $# == 0 ]; then
echo "Usage: $0 "
echo " : $0 "
echo ""
exit
fi


dir=.
if [ $# == 2 ]; then
dir=$2
fi

echo "--------------------------------------------------------------------------------"
echo "Processing ..."
echo ""

#list=`egrep -rwl "$1" $dir | egrep "\.(c|h|cpp)$"`
list=`grep -rwl "$1" $dir | grep "\.\(c\|C\|h\|H\|s\|S\|cpp\)$"`

for x in $list
do
echo "[[30;47m$x[[0m"
grep -wn "$1" $x
echo ""
done

echo "--------------------------------------------------------------------------------"

留言

張貼留言

這個網誌中的熱門文章

我弟家的新居感恩禮拜分享:善頌善禱

如何將Linux打造成OpenFlow Switch:Openvswitch

Openssl 範例程式:建立SSL連線