How to search multiple strings in a file

Hi All,

I want to search all the ksh scripts that has following details.

  1. Search for "exit 0"
  2. Search for "sqlldr" or sqlplus"
  3. In the above files i want to search for all the script that has no "case" in it.

Please advice.

Thanks,
Deep

Try this:

grep -l 'exit 0' *.ksh | xargs grep -El 'sql(ldr|plus)' | while read file
do
    grep -q case $file || echo $file
done

Or this:

for f in *.ksh
do
    awk '/exit 0/ {e=1} /sql(ldr|plus)/ { s=1 } /case/ { c=1 } END { if (e && s && !c) { print FILENAME } }' $f
done

Thanks a lot Annihilannic.
I will test this.

Regards,
Deepak