Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble using command substitution in case statement, HELP

Status
Not open for further replies.

hunternjb

Programmer
Mar 21, 2001
7
0
0
US
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

 
if you change the last line of your script to:

echo $path $srch_pri $srch_arg $act_pri $act_arg

What does it print?
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top