我是 git 和 github 的新手。我正在做一個專案,我需要將我的更改提交到特定分支中的 github 存盤庫。但我得到了錯誤
$ git commit
3.5.0.1
s/3.5.0.1/3.5.1.1/g
sed: can't read ../../build.gradle: No such file or directory
我還在此處附加了預提交檔案代碼。
#!/bin/sh
## finding the exact line in the gradle file
#ORIGINAL_STRING=$(cat ../../build.gradle | grep -E '\d\.\d\.\d\.\d')
## extracting the exact parts but with " around
#TEMP_STRING=$(echo $ORIGINAL_STRING | grep -Eo '"(.*)"')
## the exact numbering scheme
#FINAL_VERSION=$(echo $TEMP_STRING | sed 's/"//g') # 3.5.0.1
#Extract APK version
v=$(cat build.gradle | grep rtVersionName | awk '{print $1}')
FINAL_VERSION=$(echo ${v} | cut -d"\"" -f2)
echo ${FINAL_VERSION}
major=0
minor=0
build=0
assets=0
regex="([0-9] ).([0-9] ).([0-9] ).([0-9] )"
if [[ $FINAL_VERSION =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
assets="${BASH_REMATCH[4]}"
fi
# increment the build number
build=$(echo $build 1 | bc)
NEW_VERSION="${major}.${minor}.${build}.${assets}"
SED_ARGUMENT=$(echo "s/${FINAL_VERSION}/${NEW_VERSION}/g")
echo $SED_ARGUMENT
sed -i -e `printf $SED_ARGUMENT` ../../build.gradle
錯誤基本上出現在該檔案的最后一行。我正在使用窗戶。我嘗試過的事情:
sed -i -e `printf $SED_ARGUMENT` ../../build.gradle
sed -i ' ' -e `printf $SED_ARGUMENT` ../../build.gradle
我無法理解我實際上在哪里做錯了。請幫幫我。
uj5u.com熱心網友回復:
sed: can't read ../../build.gradle: No such file or directory
這個比較簡單。您的build.gradle檔案不在../../build.gradle.
解決方案是確定build.gradle檔案相對于腳本的實際路徑,并更改腳本中的路徑。
要對此進行除錯,請echo Current Directory: $PWD在腳本中查看實際作業目錄是什么,然后您應該能夠確定要使用的正確路徑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/462514.html
