我正在编写脚本,以便 for 循环使用 find 命令自动执行。我收到错误“查找:路径必须在表达式之前”
++ find alogic/batch/Instrument b/Instrument/Bank b/Instrument/container \
b/Instrument/Authorize b/Instrument/Common b/Instrument/Confirm \
-type d -type d '\(' -path alogic/batch/Instrument/BuyerCredit \
-o -path alogic/batch/Instrument/DebitCard '\)' -prune -o -name \
'*.cpp' -print
find: paths must precede expression
例如:
inclusive_directories = alogic/batch/Instrument b/Instrument/Bank b/Instrument/container b/Instrument/Authorize b/Instrument/Common b/Instrument/Confirm
exclusive_unix_notation=
-type d \( -path alogic/batch/Instrument/BuyerCredit -o -path alogic/batch/Instrument/DebitCard \)
脚本
for directory in `echo "$APPLOGIC_EXCLUSIVE" "$BIZ_EXCLUSIVE" "$PACKAGE_EXCLUSIVE" "$PIMP_EXCLUSIVE" "$OTHER_EXCLUSIVE"`
do
if [[ -d "$directory" ]]; then
#intially
if [[ "$exclusive_unix_notation" == "" ]]; then
exclusive_unix_notation=" -type d \( -path $directory"
else
exclusive_unix_notation="`echo $exclusive_unix_notation` -o -path $directory"
fi
fi
done
#if processed succesfully added the close brace
if [[ "$exclusive_unix_notation" != "" ]]; then
exclusive_unix_notation="`echo $exclusive_unix_notation` \) "
fi
# generate cpp files with files to be excluded
for files in `find $inclusive_directories $exclusive_unix_notation -prune -o -name "*.cpp" -print`
do
if [[ -f "$files" ]]; then
echo "$files"
fi
done | sed 's#^\./##' | sed 's/.cpp/.o/' | sort > $OBJ_LIST
exit;