please see below :
echo "r22543 | foobar | 2016-03-08 17:17:02 +0800 | 1 line" | egrep -o 'r[0-9]+' | egrep -o '[0-9]+'
22543
Does exist more convenient manner to get the svn revision number?
could use pcregrep, see below
echo 'r123456 foo 2016-03-17' | pcregrep -o1 'r([0-9]+)'
123456
I see it from Capturing Groups From a Grep RegEx
Use --xml
command line option and parse the xml'ed output instead of grepping.
svn log https://svn.example.com/myrepo --xml
<?xml version="1.0" encoding="UTF-8"?>
<log>
<logentry
revision="123">
<author>MyAuthor</author>
<date>2016-03-16T14:05:26.310474Z</date>
<msg>Created folder 'foo'.</msg>
</logentry>
</log>
Quite easily done with good old sed
:
echo "r22543 | foobar | 2016-03-08 17:17:02 +0800 | 1 line" | sed 's/^r\([^[:space:]]\+\).*/\1/'