How to extract a single word in a text file using a batch command.

25 pts.
Tags:
Batch files
I am trying to extract a single word from a file using a batch file. Now i know the findstr command will export the entire string, but i am just look to export a specific word from that string. I have been search for the past 2 days with no luck. The file contains the following lines and i would like export the word jason@jason.com. <<< 100 NO LOGIN jason@jason.com username/password incorrect <<< 100 NO LOGIN jason@jason.com username/password incorrect <<< 100 NO LOGIN jason@jason.com username/password incorrect <<< 100 NO LOGIN jason@jason.com username/password incorrect <<< 100 NO LOGIN jason@jason.com username/password incorrect <<< 100 NO LOGIN jason@jason.com username/password incorrect Thank You.

Software/Hardware used:
Windows server 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.

Some thing like this?
whatever.bat =
Echo off
erase new.txt
for /F “tokens=1,2,3,4,5* delims= ” %%G in (test.txt) do echo %%K >> new.txt

text.txt=
<<< 100 NO LOGIN jason@jason.com username/password incorrect
<<< 100 NO LOGIN jason@jason.com username/password incorrect
<<< 100 NO LOGIN jason@jason.com username/password incorrect
<<< 100 NO LOGIN jason@jason.com username/password incorrect
<<< 100 NO LOGIN jason@jason.com username/password incorrect
<<< 100 NO LOGIN jason@jason.com username/password incorrect

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    What exactly do you mean by "export" ?  .  Also, please let us know how you decide the word you want to export. Is it always the same word ? or is is always in the same position ?  Or does it follow a pattern ?  Can you post your current code ?
    70,000 pointsBadges:
    report
  • JmeloC
    What i mean by export is locate a single word in a string and export that one word to a text file. word will always change but it will be an email address, so the exported word will be user@domain.com or users5@domain4.com... etc. the reset of the line can be deleted or dropped. I do not have a code and that the problem I just can not find one that will do this.
    25 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following