debugDir = "/debugExamples" releaseDir = "/releaseExamples" docDir="../../../mew_devdata/interfaceDoc/" for path in `ls` do if test -d $path then echo 'test package '$path cd $path ./test.sh cd .. rm -r $docDir$path$debugDir rm -r $docDir$path$releaseDir cp -r $path$debugDir $docDir$path cp -r $path$releaseDir $docDir$path sleep 3s fi done
這里定義變量時加了空格,然后定義變量失敗,$debugDir直接就為空,結果把我幾個文件夾給刪了,早上寫的代碼沒有git add,全沒了。。。
所以以后寫腳本,運行的時候一定要先將代碼保存
debugDir="/debugExamples" releaseDir="/releaseExamples" docDir="../../../mew_devdata/interfaceDoc/" for path in `ls` do if test -d $path then echo 'test package '$path cd $path ./test.sh cd .. rm -r $docDir$path$debugDir rm -r $docDir$path$releaseDir cp -r $path$debugDir $docDir$path cp -r $path$releaseDir $docDir$path sleep 3s fi done