#!/bin/sh # if test $# = 0 -o "$1" = "-h" -o "$1" = "--help" ; then echo ' grepfind -- recursively descends directories and egrep all files ' echo '' echo ' Usage: grepfind [--help][-h][start_directory] egrep_search_pattern' echo '' echo ' The current directory is used as start_directory if parameter' echo ' start_directory is omitted. The search is case insensitive.' echo ' Multiple occurrences of control characters are replaced by a single' echo ' space. This makes it possible to grep around in files that contain' echo ' binary data and strings without setting the terminal accidently ' echo ' to graphics mode.' echo '' echo ' Example: grepfind /home "hello world" ' else if [ "$2" = "" ]; then find . -type f -exec egrep -i "$1" /dev/null {} \; | sed -e 's/[^ -~][^ -~]*/ /g' else if [ -d "$1" ];then find $1 -type f -exec egrep -i "$2" /dev/null {} \; | sed -e 's/[^ -~][^ -~]*/ /g' else echo "ERROR: $1 is not a directory" fi fi fi #__END__OF_grepfind