我有一个名为“file.txt
其中包含”的文本文件,
Combo: [email protected]:password
As Combo:
[email protected]:ajfbdf
some text here
some more text here
As Combo: [email protected]:password@1
some random text here
[email protected]:passypassyword123
[email protected]:youtube123
我正在运行下面的代码,仅从mail:pass
上面的文本文件中过滤file.txt
for /f "tokens=3" %%a in ('type file.txt^|find "As Combo:"') do >>mail.txt echo %%a
for /f "tokens=2" %%b in ('type file.txt^|find "Combo:"') do >>mail.txt echo %%b
for /f "tokens=1" %%c in ('type file.txt^|find ":"') do >>mail.txt echo %%c
的预期输出mail.txt
,
[email protected]:ajfbdf
[email protected]:password@1
[email protected]:password
[email protected]:passypassyword123
[email protected]:youtube123
但是,获得实际输出的是
[email protected]:ajfbdf
[email protected]:password@1
[email protected]:password
Combo:
Combo:
Combo:
As
As
[email protected]:passypassyword123
[email protected]:youtube123
注意:在不同的文本文件中,邮件ID和密码将有所不同。例如,上面给定的邮件ID和密码是我随机输入的。
请修复我的代码并帮助获得预期的输出。提前致谢。
尝试使用以定界符和标记为条件的查找来执行此循环...
@echo off && setlocal enabledelayedexpansion
set "_log=.\mail.txt" && cmd /v /c cd.>!_log!
for /f "tokens=* delims=" %%i in ('type .\file.txt')do echo/%%~i|find "@" >nul && (
for /f "tokens=1-3 delims=:" %%I in ('echo/%%~i')do echo/%%~I|find "@" >nul && (
set "_m_p=%%~I:%%~J")||set "_m_p=%%~J:%%~K")&& for %%E in ("%%~J")do >>!_log! (
echo/!_m_p: =!|find "@")
- 更新-受解答帖启发的版本
@somebadhat's
@rem.^
Combo: [email protected]:password^
As Combo:^
[email protected]:ajfbdf^
some text here^
some more text here^
As Combo: [email protected]:password@1^
some random text here^
[email protected]:passypassyword123^
[email protected]:youtube123
@echo off & type nul >.\mail.txt & for /f "tokens=*delims=" %%i in ('type file.txt')do (
echo=%%~i|find "@">nul && for /f "tokens=01,02,03delims=:" %%I in ('call echo=%%~i')do (
echo=%%~I|find "@">nul && set "_m_p=%%I:%%J" || set "_m_p=%%~J:%%~K") && for /f %%E in ('
echo=%%~J')do cmd /v/c "echo=!_m_p: =!"|find "@")>>.\mail.txt ||>nul call nul 2>nul 2>&1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句