I currently have a bash script which loops the results of the find command;
for k in `find $assets -iname $j -type f`
but would like to allow users to set a no-recursive parameter which will add the -maxdepth parameter to the above find command;
[ "$recurse" == "0" ] && maxdepth='-maxdepth 1'
for k in `find $assets $maxdepth -iname $j -type f`
Unfortunately, the above yields the error;
find: invalid predicate `-maxdepth=1'
However, setting two variables;
if [ "$recurse" == "0" ]
for k in `find $assets $maxdepth_param $maxdepth_val -iname $j -type f`
works perfectly but seems extraneous.
Is this the only way to accomplish this or is there a cleaner solution.
Any help much appreciated.