Findme
From Attie's Wiki
This is a nice little script that will recursively search the current directory for a string
The search_string
and file_mask
use regex... you have been warned :)
#!/bin/bash if [ "$1" = "" ]; then echo "Usage: $0 <search_string> [file_mask]"; else if [ ! "$2" = "" ]; then MYMASK=$2 else MYMASK=. fi find . -type f -not -path "*/.svn*" -printf "%p\n" | while read f; do if [ ! "`echo "$f" | grep -E -- "$MYMASK"`" = "" ]; then if [ ! "`cat "$f" | grep -i -E -- "$1"`" = "" ] ; then echo -e "\0033[93m$f\0033[0m" grep -inTE -C2 --color=always -- "$1" "$f" echo -en "\0033[94m" echo -n "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo -n "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo -e "\0033[0m" fi; fi; done; fi