1

I have a cmd command that gives me output similar to below

"Targetid = 12345"

The above string consists of \r \t \n as well. Can you please suggest a cmd command that can help me just get the number "12345" when passed with such a string

Edit: the cmd command that i use to get above string is as follow

"D:\mytest\mySoftware Query <customerGUID> | findstr /R /C:""Targetid"" "
1
  • If you provide the .cmd command which outputs the string "Targetid = 12345", we may have a fighting chance of helping. Please edit your question to include the code, formatted correctly using the {} button, and any other pertinent information. Commented Mar 19, 2018 at 20:31

1 Answer 1

2

Try like this :

@echo off

for /f "tokens=2 delims==" %%a in ('"D:\mytest\mySoftware Query <customerGUID>" ^| findstr /R /C:"Targetid"') do echo %%a
Sign up to request clarification or add additional context in comments.

1 Comment

This method also includes the \t (TAB) or space character after the equal sign. Better: for /F "tokens=3" %%a in ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.