Query the table and return values to shell script and search result values from another files.

Hi,

I need a shell script, which would search the result values from another files.

1)execute " select column1 from table_name" query on the table.
2)Based on the result, need to be grep from .wft files.

could please explain about this.Below is the way i am using.

#!/bin/sh
export db_connection_url=apps/apps@VIS
ls -l ${XXHEX_TOP}/*.wft | awk '{ if ($1 !~ /^d/) {print $9;} }' > wft_file_list.txt
while read LINE
do
names=`sqlplus -s $db_connection_url <<EOF
set pagesize 0 feedback off verify off echo off serveroutput on time off timing off 
select distinct name
from error_log;
exit
EOF
`
FILENAME=`basename $LINE`
if [ $(echo ${FILENAME} | egrep -r "$name") -eq 1 ]; then
echo "file present"
else
echo "file not present"
fi
done <wft_file_list.txt

Thank you.

To start with you are storing the sqlplus result under names variable but using $name in egrep

1 Like

yes, it is $names in egrep.
now, i am getting the below error.

./listnames.sh: line 16: [: -eq: unary operator expected
file not present
./listnames.sh: line 16: [: -eq: unary operator expected
file not present

try below if

 
 
if [ `egrep -c "$names" ${FILENAME}`  -eq 0 ]; then
echo "file not present"
else
echo "file present"
fi

1 Like

Thanks a lot for all your replies... it is working fine.