如何在centos中编写svn shell脚本

如何在centos中编写svn shell脚本,svn,centos,sh,Svn,Centos,Sh,我在CentOS有一个网站,它使用SVN进行更新和提交 我想通过crontab编写一个shell脚本来自动运行调度工作 我测试了一个SVN命令,SVN status | grep^? 它向我显示如下结果: M index.php<br/> M data/config.php<br/> ? date/aaa.php<br/> ? images/bbb.php<br/> ? images/product1.jpg<br/> ? images

我在CentOS有一个网站,它使用SVN进行更新和提交

我想通过crontab编写一个shell脚本来自动运行调度工作

我测试了一个SVN命令,SVN status | grep^?
它向我显示如下结果:

M index.php<br/>
M data/config.php<br/>
? date/aaa.php<br/>
? images/bbb.php<br/>
? images/product1.jpg<br/>
? images/product2.jpg<br/>
? themes/ccc.php<br/>
? themes/index.html<br/>
? temp/compiled/index.php<br/>
? temp/compiled/article.php<br/>
? temp/compiled/footer.php<br/>
M index.php
M data/config.php
? 日期/aaa.php
? images/bbb.php
? images/product1.jpg
? images/product2.jpg
? themes/ccc.php
? themes/index.html
? temp/compiled/index.php
? temp/compiled/article.php
? temp/compiled/footer.php
我编写了一个SVN命令,可以删除所有的universion并修改php文件,如下所示:

M index.php<br/>
M data/config.php<br/>
? date/aaa.php<br/>
? images/bbb.php<br/>
? images/product1.jpg<br/>
? images/product2.jpg<br/>
? themes/ccc.php<br/>
? themes/index.html<br/>
? temp/compiled/index.php<br/>
? temp/compiled/article.php<br/>
? temp/compiled/footer.php<br/>
svn状态——不要忽略| grep.php$“| sed's/^?/”|xargs rm-rf

我想写一个可以帮助我的shell脚本:

  • 删除非版本文件,但修改文件除外
  • 仅删除php文件
  • 例外文件临时文件夹

请帮助我,谢谢大家使用grep和选项
-v
排除temp下的文件路径。为了使命令更安全,我还将跳过
rm
命令中的
-r
-f

svn status --no-ignore | grep '^?.*\.php$' | grep -v '^? *temp/' | sed 's/^? *//' | xargs rm

请记住,
grep'x'| sed's/y/z/'
可以重构为
sed-n'/x/s/y/z/p'
。您还可以通过类似的重构轻松摆脱最后一个
grep
。请参阅@ PrPress除了简洁和效率之外,我们还需要考虑那些不是SED专家(像我)的可读性。另一个可读的选择是使用awk。我有一台windows系统的计算机。如何在windows蝙蝠中执行相同的工作?@breakgood我已经阅读了sed,但我不知道如何编写此命令。