Page 1 of 1

Batch File Search

Posted: 21 Nov 2012 08:22
by krunoo
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

Re: Batch File Search

Posted: 21 Nov 2012 09:13
by foxidrive
Try this:

Code: Select all

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

Re: Batch File Search

Posted: 21 Nov 2012 10:22
by krunoo
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

Re: Batch File Search

Posted: 21 Nov 2012 10:32
by RogerSmith
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

Re: Batch File Search

Posted: 22 Nov 2012 02:40
by krunoo
thank you. this is great.

Re: Batch File Search

Posted: 23 Nov 2012 06:57
by krunoo
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.

Re: Batch File Search

Posted: 23 Nov 2012 07:21
by foxidrive
can the domain name appear more than once?

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

Re: Batch File Search

Posted: 23 Nov 2012 09:16
by krunoo
yes, domain name appear more than once.

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

Re: Batch File Search

Posted: 23 Nov 2012 11:08
by foxidrive
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"

Re: Batch File Search

Posted: 04 Dec 2012 03:28
by krunoo
thank you