سؤال

I have a FINDSTR that looks like this:

lots of stuff here | FINDSTR ro.redacted.version.release=

it outputs:

ro.redacted.version.release=THIS.IS.THE.PART.I.WANT

FINDSTR does not play very well with regex, I have tried just about everything that an in-depth Google search throws at me with no luck. Does any one know a way to get the

THIS.IS.THE.PART.I.WANT

as output instead of

ro.redacted.version.release=THIS.IS.THE.PART.I.WANT

Some background: This is part of a VBA inside Excel, it opens cmd, uses ADB to pull build version from a phone and then uses that data to do other stuff. Everything else is up and running, so I'd rather not change approach if avoidable.

هل كانت مفيدة؟

المحلول

Findstr is a simple 'show the text' program with no way to extract part of a line.

Findstr is also buggy in many ways - there is a good page by dbenham on all the issues.

You can use a for /F command to extract parts of the line. Knowing the exact text in the line up until the part that you want is important - if there is an equals sign between the two parts (and no other equals sign before that) then it's straightforward.

for /f "tokens=1,* delims==" %%a in ('findstr "ro.redacted.version.release=" "c:\folder\file.txt" ') do echo "%%b"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top