一个简单的脚本,利用数组、函数和for

#!/bin/bash
svnUrl=( #数组
     url1
     url2
     )
    
targetDir=~/odp/app/groupon

buildModule()
{         
     echo $2
     svn co $2 temp
     cd temp
    
     find ./ -name .svn -exec rm -rf {} \;
     if [ -d  actions ];
     then
          echo actions
          cp actions $1/ -r
     fi

     if [ -d  models ];
     then
          echo models
          cp models $1/ -r
     fi

     if [ -d  library ];
     then
          echo library
          cp library $1/ -r
     fi

     if [ -d  script ];
     then
          echo script
          cp script $1/ -r
     fi

     if [ -d  controllers ];
     then
          echo controllers
          cp controllers $1/ -r
     fi    
    
     #cd ..
     #rm temp -rf
}

if [ ! -d $targetDir ];
then
     echo "make app root dir"
     mkdir $targetDir -p
fi

for i in ${svnUrl[*]} #数组遍历
do
     echo $i
     buildModule $targetDir, $i
done

 

你可能感兴趣的:(for)