2

I have the file called file.txt which contains,

American 9876543 america@gmail.com
Australian 7674840 Australia@mail.com
Indian 9364906 india@ymail.com
Chinese 6383936 china@mail.com
Japanese 9363839 Japan@hotmail.com

Now i want to filter three things from this file as output in another text file.

For example,

output file1.txt - need to contain all mail id's

america@gmail.com
Australia@mail.com
india@ymail.com
china@mail.com
Japan@hotmail.com

output file2.txt - need to contain all numbers

9876543
7674840
9364906
6383936
9363839

output file3.txt - need to contain only the sequence word starting at A,

for example,

American
Australian

For this i tried using FC command and Findstr commands.. And i have No idea how to do these with those commands correctly.

Please help.. Thanx in Advance..

3

I want to filter three things from this file as output in another text file

You don't need fc or findstr to do this. A simple for /f command will suffice.

Use the following batch file (test.cmd):

@echo off
setlocal enabledelayedexpansion
for /f "usebackq tokens=1-3" %%a in (`type file.txt`) do (
  echo %%a >> file3.txt
  echo %%b >> file2.txt
  echo %%c >> file1.txt
  )
endlocal

Example usage:

> type file.txt
American 9876543 america@gmail.com
Australian 7674840 Australia@mail.com
Indian 9364906 india@ymail.com
Chinese 6383936 china@mail.com
Japanese 9363839 Japan@hotmail.com

> test

> type file1.txt
america@gmail.com
Australia@mail.com
india@ymail.com
china@mail.com
Japan@hotmail.com

> type file2.txt
9876543
7674840
9364906
6383936
9363839

> type file3.txt
American
Australian
Indian
Chinese
Japanese

Further Reading

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.