#!/bin/sh # # lookin # # AUTHOR: # Dan Harkless # # COPYRIGHT: # This file is Copyright (C) 2003 by Dan Harkless, and is released under the # GNU General Public License . # # USAGE: # % lookin '' '' # % lookin -src '' # # DESCRIPTION: # When looking for strings in a file hierarchy, it's a pain to have to type # out big long 'find' commands. This script provides a simple and intuitive # syntax for having 'find' call my 'bgrep' command on filenames matching a # specific pattern. For instance, you can type: # # % lookin '*.el' emacs-version # # find's filename wildcarding is not as powerful as full regular expressions, # so unfortunately it isn't possible to specify some complex name tests with # this script. The most common file category I need to grep through, in fact, # is one of these -- assembly, C, and C++ files. Therefore, there's a special # 'lookin -src' variant that looks through such files: # # % lookin -src exit # # DATE MODIFICATION # ========== ================================================================== # 2003-03-30 Renamed bgrep's -b option as --blank now that it can accept egrep # options (one of which is called -b). # 1998-02-24 Original. if [ $# -lt 2 ]; then echo "usage: lookin '' ''" echo "usage: lookin -src ''" exit 1 fi if [ X$1 = X-src ]; then find * -follow \( -name "*.[chsS]" -o -name "*.[ch]pp" \) \ -exec bgrep --blank "$2" {} \; else find * -follow -name "$1" -exec bgrep --blank "$2" {} \; fi