仅获取svn log -verbose中的文件提交信息

时间:2013-05-13 19:00:13

标签: svn unix sed awk cut

如何仅获取从svn -verbose

输出的文件
  svn log -v  . -r 101
  ------------------------------------------------------------------------
  r101 | username | 2013-05-10 16:27:55 -0400 (Fri, 10 May 2013) | 1 line
  Changed paths:
     M /branches/1.0/ssac/codes/filename1.java
     M /branches/1.0/ssac/extn/filename2.java
     M /branches/1.0/ssac/extn/filename3.java
     M /branches/1.0/ssac/extn/filenmae4.java
     M /branches/1.0/ssac/extn/filename5.java
     M /branches/1.0/vclpcc/filename6.java
Ticket-1

我厌倦了这个:

  svn log -v  . -r 101 | awk '/Changed paths/{ P=1; next } /Ticket-1/ {exit} P'

输出:

 M /branches/1.0/ssac/codes/filename1.java
 M /branches/1.0/ssac/extn/filename2.java
 M /branches/1.0/ssac/extn/filename3.java
 M /branches/1.0/ssac/extn/filenmae4.java
 M /branches/1.0/ssac/extn/filename5.java
 M /branches/1.0/vclpcc/filename6.java

有更好的方法吗?并截断“M”元数据?

预期输出:

 /branches/1.0/ssac/codes/filename1.java
 /branches/1.0/ssac/extn/filename2.java
 /branches/1.0/ssac/extn/filename3.java
 /branches/1.0/ssac/extn/filenmae4.java
 /branches/1.0/ssac/extn/filename5.java
 /branches/1.0/vclpcc/filename6.java

2 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

$ svn log -v . -r 101 | awk '$1~/^[AMD]$/{for(i=2;i<=NF;i++)print $i}'
/branches/1.0/ssac/codes/filename1.java
/branches/1.0/ssac/extn/filename2.java
/branches/1.0/ssac/extn/filename3.java
/branches/1.0/ssac/extn/filenmae4.java
/branches/1.0/ssac/extn/filename5.java
/branches/1.0/vclpcc/filename6.java

答案 1 :(得分:-2)

svn log -v | grep '^[ADMR]' | gawk {print $2}

如果我忘记了某些状态,可以将它们添加到grep-string