在 Windows 批处理脚本中从 SVN 获取一组修订
我正在编写一个用于同步 SVN 存储库的脚本。这是我的第一个 Windows 批处理脚本,因此我遇到了一些问题。我使用“svn log -q”命令,它给出了存储在 SVN_LOG_Q_FILE 中的修订号:
------------------------------------------------------------------------
r4 | username | 2011-05-26 13:31:04 +0100
------------------------------------------------------------------------
r3 | username | 2011-05-26 13:27:33 +0100
------------------------------------------------------------------------
r2 | username | 2011-05-26 15:39:29 +0100
------------------------------------------------------------------------
r1 | username | 2011-05-26 13:37:41 +0100
------------------------------------------------------------------------
我想得到的只是修订号。我使用下面的代码来获取修订,但它们带有前导“r”(r1、r2 等)。
for /f "usebackq tokens=1" %%g in (`findstr /r /c:"r" %SVN_LOG_Q_FILE%`) do (
echo rev %%g%
)
你能帮助我吗?
提前致谢, 塞尔登
I'm writing a script for synchronisation of SVN repositories. It's my first Windows batch script, so I have some problems with it. I use "svn log -q" command which gives revision numbers like this that are stored in SVN_LOG_Q_FILE:
------------------------------------------------------------------------
r4 | username | 2011-05-26 13:31:04 +0100
------------------------------------------------------------------------
r3 | username | 2011-05-26 13:27:33 +0100
------------------------------------------------------------------------
r2 | username | 2011-05-26 15:39:29 +0100
------------------------------------------------------------------------
r1 | username | 2011-05-26 13:37:41 +0100
------------------------------------------------------------------------
What I'd like to get is only revision numbers. I use below code for getting revisions, but they're with leading "r" (r1, r2 etc.).
for /f "usebackq tokens=1" %%g in (`findstr /r /c:"r" %SVN_LOG_Q_FILE%`) do (
echo rev %%g%
)
Can you help me?
Thanks in advance,
szeldon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
带有 delims
和r
的简单 FOR /F 应该可以工作,因为 r 后面总是有一个空格。A simple FOR /F with the delims
<space>
andr
should work, as there is always a space behind the r.