I am with the others above in that the issue appears to be you have put too much in to the script.
If I have understood the issue, you need the following 3 things removed:
1. the "break" in the 'Y' section is not required as this will break the infinite loop and hence your script will only run once
2. the "file" variable and replace it with TARGET_FILE
3. the exec, as above this is not required to run the program you have listed
So the new copy would be:
Code:
while true; do
read -p "Do you want to scan another file? (y\n) " yn
case $yn in
[Yy]* ) unset TARGET_FILE
ls -h
read -p "Enter the name of the file: " TARGET_FILE
./runpe "$TARGET_FILE";;
[Nn]* ) break;;
esac
done
If you want to be really nice to your users, have a look at the "select" command (help select)