2

只需要svn log中的目录名和文件更改信息

这是我的 svn 日志

svn log -v http://test/svn/Demo/branches/HelloWorld/Batch/ --limit 2

------------------------------------------------------------------------
r133 | testuser1 | 2013-04-02 18:22:28 -0400 (Tue, 02 Apr 2013) | 3 lines
Changed paths:
M /branches/HelloWorld/Batch/test.java

DEMO-13
Testing to lock 

------------------------------------------------------------------------
r132 | testuser2 | 2013-04-02 18:20:40 -0400 (Tue, 02 Apr 2013) | 3 lines
Changed paths:
M /branches/HelloWorld/Batch/test.java

DEMO-1
Testing to lock

期望的输出:

Batch/test.java
Batch/test.java

我的脚本:

 svn log -v http://test/svn/Demo/branches/HelloWorld/Batch/ --limit 2 | awk '$1~/^[AMD]$/{for(i=2;i<=NF;i++)print $i}'

脚本输出:

/branches/HelloWorld/Batch/test.java
/branches/HelloWorld/Batch/test.java
4

2 回答 2

1

怎么样:

what ever process you are running | awk -v FS="[/ ]" '$1~/^[AMD]$/{print $(NF-1)"/"$NF}'

测试:

[jaypal:~/Temp] cat svn.log
svn log -v http://test/svn/Demo/branches/HelloWorld/Batch/ --limit 2

------------------------------------------------------------------------
r133 | testuser1 | 2013-04-02 18:22:28 -0400 (Tue, 02 Apr 2013) | 3 lines
Changed paths:
M /branches/HelloWorld/Batch/test.java

DEMO-13
Testing to lock

------------------------------------------------------------------------
r132 | testuser2 | 2013-04-02 18:20:40 -0400 (Tue, 02 Apr 2013) | 3 lines
Changed paths:
M /branches/HelloWorld/Batch/test.java

DEMO-1
Testing to lock
[jaypal:~/Temp] awk -v FS="[/ ]" '$1~/^[AMD]$/{print $(NF-1)"/"$NF}' svn.log
Batch/test.java
Batch/test.java
于 2013-06-19T22:27:05.423 回答
1

您几乎只需将字段分隔符设置为空格或正斜杠并在匹配行上打印最后两个字段:

awk '$1~/^[AMD]$/{print $(NF-1),$NF}' FS=' |/' OFS='/'

输出将是:

Batch/test.java
Batch/test.java
于 2013-06-19T22:28:50.757 回答