I have trouble using command substitution with find command options in a case statement. Below I have written a condensed version of an example. The problem part is indicated below between to lines of #. When the script executes it gives me a "find: incomplete statement" error. The problem is statements cat {} \; and rm {} \; inside the case statements but I just don't know how to fix it. I need some help. Here is an example of my problem:
echo "\n\t 1)Search based on filename"
echo "\n\t 2)Search based on user"
echo "Number Choice: \c"
read pchoice
case $pchoice in
1)srch_pri='-name';;
2)srch_pri='-user';;
esac
case $pchoice in
1)"Filename: \c"; read srch_arg;;
2)"User: \c"; read srch_arg;;
esac
echo "Please select number of action"
echo "\t\n 1)Display file contents"
echo "\t\n 2)Remove file"
echo "Choice: \c"
read achoice
case $achoice in
1)act_pri='-exec';;
2)act_pri='ok';;
esac
########################################################
case $achoice in
1)act_arg='cat {} \;';;
2)act_arg='rm {} \;';;
esac
########################################################
path=$HOME
find $path $srch_pri $srch_arg $act_pri $act_arg
echo "\n\t 1)Search based on filename"
echo "\n\t 2)Search based on user"
echo "Number Choice: \c"
read pchoice
case $pchoice in
1)srch_pri='-name';;
2)srch_pri='-user';;
esac
case $pchoice in
1)"Filename: \c"; read srch_arg;;
2)"User: \c"; read srch_arg;;
esac
echo "Please select number of action"
echo "\t\n 1)Display file contents"
echo "\t\n 2)Remove file"
echo "Choice: \c"
read achoice
case $achoice in
1)act_pri='-exec';;
2)act_pri='ok';;
esac
########################################################
case $achoice in
1)act_arg='cat {} \;';;
2)act_arg='rm {} \;';;
esac
########################################################
path=$HOME
find $path $srch_pri $srch_arg $act_pri $act_arg