Batch File Search

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Batch File Search

#1 Post by krunoo » 21 Nov 2012 08:22

Hello,

I need help!

I have txt file with a lot text inside. Every row is for itself.

Format look somethink like this.

first.last@domena.tld:*password*:blablablallb dsaldasl da lkasdlas ldk
first2.last2@domena2.tld:*password*:blablablallb dsaldasl da lkasdlas ldk
first3.last3@domena3.tld:*password*:blablablallb dsaldasl da lkasdlas ldk

I want to search domena.tld and have output like this:
first.last@domena.tld - password
first2.last2@domena.tld - password
....

Can someone help me?

Thx, Kruno

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch File Search

#2 Post by foxidrive » 21 Nov 2012 09:13

Try this:

Code: Select all

@echo off
for /f "tokens=1,2 delims=:" %%a in (file.txt) do echo %%a - %%b

krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Re: Batch File Search

#3 Post by krunoo » 21 Nov 2012 10:22

this is great. thank you. a step forward.

can you customize this in the way, that I insert the domain and script find only that?

thank you once more

RogerSmith
Posts: 22
Joined: 20 Nov 2012 12:42

Re: Batch File Search

#4 Post by RogerSmith » 21 Nov 2012 10:32

using foxi code

@echo off
for /f "tokens=1,2 delims=:" %%a in (file.txt) do echo %%a - %%b | findstr /l /i "DOMAIN_CHANGE_THIS_"

its all one line except @echo off that is in the first line

If you want something with user input

@echo off
:a
echo Enter Domain
set /p dom=
for /f "tokens=1,2 delims=:" %%a in (file.txt) do echo %%a - %%b | findstr /l /i "%dom%"
echo.
echo.
pause
goto a

krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Re: Batch File Search

#5 Post by krunoo » 22 Nov 2012 02:40

thank you. this is great.

krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Re: Batch File Search

#6 Post by krunoo » 23 Nov 2012 06:57

hello, its me again. :(

now i have this issue.

i have file with mailling lists and it looks somethink like this.
list name@domain.tld
data1
data2
data3
data4
data5
.
.
.
data24
list name2@domain2.tld

Now I want to enter domain and find every list with this domain and print list name and all data to next list.

I this posible and have?

thanks again.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch File Search

#7 Post by foxidrive » 23 Nov 2012 07:21

can the domain name appear more than once?

Is "list" in column 1 actually part of the file?

krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Re: Batch File Search

#8 Post by krunoo » 23 Nov 2012 09:16

yes, domain name appear more than once.

"list" is not a part of the file. its word which start every mailling list.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch File Search

#9 Post by foxidrive » 23 Nov 2012 11:08

Without knowing the exact text to search for, this is all I can provide.

Download GnuSed and then use this batch file.

EDITED AGAIN:


Code: Select all

@echo off
sed "/@domain.tld/,/^list/"!d "file.txt"

krunoo
Posts: 10
Joined: 21 Nov 2012 08:15

Re: Batch File Search

#10 Post by krunoo » 04 Dec 2012 03:28

thank you

Post Reply