有人可以帮我弄清楚为什么我会收到这个错误,语法错误接近意外令牌`do'。我试过研究答案但到目前为止没有运气。下面是我的代码的一部分
while
do
if [[ "${ScanConfirm}" == "Y" ]]; then
# use a for Loop to scan the chosen directory and for every non-MDF file in the directory it creates an MDF file in a temp-MDF directory
XCOUNT=0
echo
echo "Scanning Directory.. this may take a few minutes"
echo "*************************************************"
echo
export TEMP_MDF="${StartingDir}/MDF_${RANDOM}"
mkdir -p ${TEMP_MDF}
for FILE in `find ${Dir2Scan} -type f`
do
export ERRORFILE=${FILE}
BASEFILE=`basename ${FILE}`
BASEDIR=`dirname ${FILE}`
# echo priority 50 >>"${TEMP_MDF}/${BASEFILE}.mdf" <----------- you can take out this arrow and uncomment this to put in priorities
# echo categoryName=${Category} >> "${TEMP_MDF}/${BASEFILE}.mdf" <----------- if you want the category you entered about to show up in MDF you need to uncomment the lines above this note
echo objectName=${RANDOM}${RANDOM}_${NamePrefix}_${BASEFILE} >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo "<comments>" >>"${TEMP_MDF}/${BASEFILE}.mdf"
echo "${Comments}" >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo "</comments>" >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo "originalServer=${BASEDIR}">>"${TEMP_MDF}/${BASEFILE}.mdf"
# echo "originalPath=${BASEDIR}">>"${TEMP_MDF}/${BASEFILE}.mdf"
chaine=`basename ${BASEDIR}`
# echo "sourceDestinationDIVAPath=${chaine}" >>"${TEMP_MDF}/${BASEFILE}.mdf"
echo >> "${TEMP_MDF}/${BASEFILE}.mdf"
echo "<fileList>" >>"${TEMP_MDF}/${BASEFILE}.mdf"
mv "${TEMP_MDF}/${BASEFILE}.mdf" "${TEMP_MDF}/${BASEFILE}_${RANDOM}.mdf"
ERRORLEVEL=$?
if [ ${ERRORLEVEL} -ne 0 ]; then
Stop
fi
XCOUNT=$((${XCOUNT}+1))
echo "${XCOUNT}/${OriginalCount} MDF Files Created ${BASEFILE}.mdf"
done
答案 0 :(得分:0)
来自help while
:
while:while COMMANDS;做命令;完成
在语法中,COMMANDS
都不是可选的。
如果您想要无限循环,请考虑:
while :; do
或
while true; do
...语义相同(:
和true
都是内置命令,无条件退出状态为0)。