I have a script (find_keyword.ksh) that reads data from a txt (keyword.txt) file and produces results if any word in txt files matches in the directory containing files that end with .ksh
I pass directory path at the time of script execution.
I am facing two issue that I would like some tips on. 1) Current script only searches for only upper case. I would like it to read lower case keywords from txt file and search them as well. 2) In the same script I want to search keywords not only in .ksh files, but *.sql.*
I tried, but can’t seem to find how to include item 1 & 2. Any help will be highly appreciated. I am using solaris 10.
Sample: Keyword.txt
NUMBER
AUTO
number
PARTITION
find_keyword.ksh:
#!/bin/ksh
SCRIPTDIR=$1
# Location of the keyword file:
RSVWDS=/name/europa/keyword.txt
cd $SCRIPTDIR
nawk -F'[ ()+-;]' -v words=$RSVWDS '
BEGIN{n=0; while ((getline line < words ) > 0){ n=n+1; rw[n]=line;} close(words);}
{for(k=1;k<=NF;k++){
l0=toupper($k); w=0;
for(i in rw){if(length(l0)>0&&l0==rw) w=w+1;}}
if(w>0){print FILENAME": "FNR" : "$0}
}' *.*ksh
exit
I pass directory path at the time of script execution.
I am facing two issue that I would like some tips on. 1) Current script only searches for only upper case. I would like it to read lower case keywords from txt file and search them as well. 2) In the same script I want to search keywords not only in .ksh files, but *.sql.*
I tried, but can’t seem to find how to include item 1 & 2. Any help will be highly appreciated. I am using solaris 10.
Sample: Keyword.txt
NUMBER
AUTO
number
PARTITION
find_keyword.ksh:
#!/bin/ksh
SCRIPTDIR=$1
# Location of the keyword file:
RSVWDS=/name/europa/keyword.txt
cd $SCRIPTDIR
nawk -F'[ ()+-;]' -v words=$RSVWDS '
BEGIN{n=0; while ((getline line < words ) > 0){ n=n+1; rw[n]=line;} close(words);}
{for(k=1;k<=NF;k++){
l0=toupper($k); w=0;
for(i in rw){if(length(l0)>0&&l0==rw) w=w+1;}}
if(w>0){print FILENAME": "FNR" : "$0}
}' *.*ksh
exit