#!/bin/bash
echo "Executing Script to run sql files one by one......"

echo "Enter the directory which has folders of scripts having sql files: "
read PATH_DIR

for dir in $PATH_DIR/*; do
echo "Directory is $dir"
if [ -d "$dir" ]; then
echo "Enter the directory: $dir......"
cd $dir
x=$(pwd)
echo "The current working directory : $x"
for FILE in *; do
echo "Executing file $FILE using db2 command...."
db2 -tvmf $FILE
done;
echo "Exit the directory: $dir"
cd ..
fi
done;