实现原理:通过svn info
查看svn信息,使用grep
获取版本信息,用awk
获取版本号,然后对比版本号是否需要更新
#!/bin/sh
revision=`svn info |grep "Last Changed Rev:" |awk '{print $4}'`
echo "the revision is $revision"
URL=`svn info |grep ^URL: |awk '{print $2}'`
echo "the url is $URL"
svnRevision=`svn info $URL |grep "Last Changed Rev:" |awk '{print $4}'`
echo "the revision in svn is $svnRevision"
if [[ $revision < $svnRevision ]] ; then
echo "need svn up"
svn up
echo "svn up finish"
else
echo "no need svn up"
fi