I'm trying to get the revision number from a svn update
command output. In the file tmpFile.txt
I've got the string At revision 58998.
I've run the following command:
findstr /r "\<[0-9][0-9]*\>" "tmpFile.txt"
and I've got
At revision 58998.
Also, running with
findstr /r /o "\<[0-9][0-9]*\>" "tmpFile.txt"
I get
0:At revision 58998.
What's going on and how can I get only the number?
FINDSTR prints out the entire line that matches. It is not able to extract just the matching portion of the line.
You can use FOR /F to parse the output and get just the number.
for /f "tokens=3 delims=. " %%A in (
'findstr /rc:"At revision [0-9][0-9]*\." "tmpFile.txt"'
) do echo %%A