[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sample script (was Re: grep : -r ... )
From: |
Andrew L. Moore |
Subject: |
sample script (was Re: grep : -r ... ) |
Date: |
Mon, 03 Sep 2001 21:18:07 -0700 |
In message <address@hidden>, Andre Gompel writes:
>Hello:
>grep : -r (recursive) option does not work in the follwing context:
>
>grep -ri string *.c
If typing "find -X . '*.c' | xargs -n30 grep string" is tiresome,
you might try something like the script below. Sample usage:
$ ffn -il string '*.c'
NB: quote the file glob to avoid expansion by the shell
---- Cut Here ----
#!/bin/ksh -
#
# @(#)ffn 1.0
#
# This script greps files matching a pattern under the current folder.
#
umask 077
PATH=/bin:/usr/bin
integer i=0
integer j=0
USAGE="usage: ffn [egrep-options] egrep-pattern [file-glob ...]"
while :; do
[ $# -gt 0 ] ||
{ echo $USAGE >&2; exit 2; }
arg="$1"
shift
case "$arg" in
"")
;;
--)
break
;;
-*)
egrep_arg[i++]="$arg"
;;
*)
egrep_arg[i++]="$arg"
break
;;
esac
done
(( i>0 )) || { echo $USAGE >&2; exit 2; }
for file_glob; do
find_arg[j++]="-name '$file_glob'"
done
eval find -X . "address@hidden" | xargs -n30 egrep "address@hidden"