Reputation: 15076
This is the output of some svn log
command of me
------------------------------------------------------------------------
r23327 | xxx | 201x-0x-1x 15:09:20 +0200 (Mon, x x x) | 1 line
Changed paths:
A /line/tags/1.1.1.1 (from /line/branches/uat:23326)
I want to grep or sed the nummber 23327
out of the output. Someone who can help me? I want it to work too with other numbers but same layout.
I tried something like
txt | grep '^r'
r23327 | xxx | 2017-05-15 15:09:20 +0200 (Mon, 15 May 2017) | 1 line
But I need to get rid of the 'r' and stop before the space before |
Upvotes: 1
Views: 23
Reputation: 92854
sed approach:
sed -n 's/^r\([[:digit:]]*\) .*/\1/gp' file
The output:
23327
\([[:digit:]]*\)
- captured group for digits preceded by r
Or with grep (PCRE):
grep -Po '^r\K[0-9]+ ' file
-P
- allows PCRE
\K
- ignores matches till the current position (i.e. ignore r
before digits)
Upvotes: 1