the find command is:
find ./ \( -path dir_a -o -path dir_b \) -prune
I want to convert to:
./find.sh dir_a dir_b
so my code (is doesn't work):
function myfind() {
num=1
tmp=""
for i in $@
do
tmp="$tmp -path './$i' "
if [ $((num++)) -ne $# ]
then
tmp="${tmp} -o"
fi
done
echo $tmp # this is ok!!
find ./ \( $tmp \) -prune # is doesn't work, why???
}
tmpUse array instead. Check last code snippetunderquotingin this link$@unquoted is clearly wrong. It needs to be in double quotes to have its special meaning, distinct from$*(quoted or unquoted).