[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

searching files for patterns



need your help

is this the best/fastest way to search through 800,000 hl7 files?

for each file i am grepping for 6 names... thus each file is
scanned/grepped 6 times over.  Basically i am searching for 1 name in 4 1/2
million files.  Even though the server is fast, it is still processing on
average 2 files per second.

here is my script...  any thoughts would be appreciated as we have a tight
schedule.


cd /backup/Loaders/Ld21/HL7FILES
#for file in `find * -print`
for file in `ls`
do
  while read name
  do
    search=`cut -d "|" -f 20 < $file | grep $name`	{extracts name from
field 20 of hl7 file}
    if [ "$search" > /dev/null ]
    then
      dir=`pwd`
      echo "$name -> $dir/$file" >> /home/zane/found.list	{adds found names
 and relevant filenames}
    fi
  done < /home/zane/scripts/filelist	{file containing the six names to
search for}
done
~



Reply to: