我试图用这种方式读取两个文件:
if [[ $COPY_PREV_DEPLOYMENT == true ]]; then
echo [$JOB_NAME] Copying old environment variables of $OLD_APP app to the new environment variables of $NEW_APP app...
cf env $NEW_APP | awk '/User-Provided/,/No staging env variables have been set/'| cut -f1 -d":" | tail -n +2 > env_variables.txt
cf env $OLD_APP | awk '/User-Provided/,/No staging env variables have been set/'| cut -f2 -d":" | tail -n +2 > env_variables_values.txt
paste env_variables.txt env_variables_values.txt | while read -r VARIABLE VALUE
do
cf set-env "$NEW_APP" "$VARIABLE" "$VALUE"
done
echo [$JOB_NAME] Done.
fi
但我正面临这个问题
..... sh:第61行:意外令牌
do' ......sh: line 61:
附近的语法错误('
有人可以帮我解决吗?
非常感谢
答案 0 :(得分:0)
在do
条件之后,您不会使用if
。 do... done
主要用于loops。此外,似乎不需要括号来从cloudfoundry api包装此单个执行语句。
代码可能如下所示:
if [[ $COPY_PREV_DEPLOYMENT == true ]]; then
echo $JOB_NAME Copying old environment variables of $OLD_APP app to the new environment variables of $NEW_APP app...
cf env $NEW_APP | awk '/User-Provided/,/No staging env variables have been set/'| cut -f1 -d":" | tail -n +2 > env_variables.txt
cf env $OLD_APP | awk '/User-Provided/,/No staging env variables have been set/'| cut -f2 -d":" | tail -n +2 > env_variables_values.txt
paste env_variables.txt env_variables_values.txt | while read -r VARIABLE VALUE; do
cf set-env "$NEW_APP" "$VARIABLE" "$VALUE"
done
echo $JOB_NAME Done.
fi