Okay, I spent way too long writing this simplistic script and debugging
it, and suddenly, I try it out on another machine and I get complaints
about grep usage AND that bin is not executable (I'm not trying to
execute it, it's a directory and has execute permissions, so I can read
the directory!).
The difference is that I wrote it on an AIX 4.1 machine, and it fails
miserably under AIX 3.2.
Both the "-v" and "-l" options for grep are supported by the earlier
AIX.
The shell used is Korn.
The whole idea is to do a fast search of all source code, without
hardcoding specific source subdirectories and avoiding searching things
which are obviously not source code. (On the machine I wrote the script
on, this cut the search to about 2.5 minutes, down from 10-15 minutes,
for a simple find, followed by grep).
The script:
PATTERN=${1}
ls ${SRCDIR} | grep -v ^bin | grep -v ^rpt | grep -v ^tmp | \
grep -v "\.o$" | grep -v "\.4ge$" | \
xargs grep -l ${PATTERN}
basically it gets a list of everythings in the source directory,
excluding ones where source code will never be present,
finds all the files in those directories,
excluding object and binary files
amd greps for the pattern, returning a list of all files referencing
the pattern.
I have abbreviated the list of directories and file types excluded, but
not by very much. Also, note, that if I didn't cut and paste the above
code, so bear in mind that it does work under AIX 4.1.
Please, any suggestions will be listened to with great interest, and if
I can fix it, I will post the fix, however, I am reasonably confident
that this should work under just about any unix!
This would not be the first time, AIX has been very bad to me;
does anyone know why IBM still has the market presence outside of the
mainframe world???
Incidentally AIX 4.1 contains a particularly * bug that set
the record for number of pager calls in a week at my company, so please
don't tell me the answer is to upgrade (it's our customer's decision
anyway, and I'd sooner they'd invest their upgrade dollars into
frame relay as modems just don't cut it in the business world today!)
Thanx in advance,
#include <StdDisclaimers.h>