Reputation: 15086
I did some svn to git migration. Now I use git log to find the svn revision (which is described in the commit message of git).
$ git log -1 11.10.11.0
output
commit 84a1f5fb6xxx4607e6ed5623eab15ecdbacf
Author: USER <USER>
Date: Wed Apr 12 08:27:08 2017 +0000
git-svn-id: https://svn-repo.com/repo/proj/tags/11.10.11.0@12000 f25b8xx2b0-ax00-41x2-87xx1-abxxxxe8fa
Now I want to use sed to filter the revision number (12000
) in this case. What's the most generic way to do this?
Upvotes: 0
Views: 833
Reputation: 4043
The awk
command can meet your requirement, take a look at below,
git log -1 11.10.11.0 | awk -F'@' '{printf "%s",$2}' | awk '{print $1}'
12000
Upvotes: 1
Reputation: 18381
sed
approach: Here sed
two actions are performed by sed. One is to only print the desired line and other is to print the desired section of line.
<git-command>|sed -r '/git-svn-id/!d;s/.*@([^ ]+).*/\1/'
12000
If grep
is acceptable approach to you:
<git-command>|grep -oP 'git-svn-id.*?@\K[^ ]+'
12000
If awk
is acceptable:
<git-command>|awk '/git-svn-id/{n=split($2,a,"@");print a[n]}'
12000
Upvotes: 3