All pastes #1012042 Raw Edit

grepfind

public shellscript v1 · immutable
#1012042 ·published 2008-05-08 21:27 UTC
rendered paste body
#!/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 {} \;    else        if [ -d "$1" ];then            find $1 -type f -exec egrep -i "$2" /dev/null {} \;        else             echo "ERROR: $1 is not a directory"        fi    fifi#__END__OF_grepfind