标题: [文本处理] 怎么用批处理整理这个文本 [打印本页]
作者: shuiping5566 时间: 2010-1-26 15:48 标题: 怎么用批处理整理这个文本
原文本123.txt如下:
results|61.146.0.86|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
summary|61.146.0.86|OS: Unknown OS; PORT/TCP:
results|61.146.92.34|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">infox1eies2sps3was4!</font>"
summary|61.146.92.34|OS: Unknown OS; PORT/TCP:
results|112.94.74.118|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
summary|112.94.74.118|OS: Unknown OS; PORT/TCP:
results|112.97.226.41|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
summary|112.97.226.41|OS: Unknown OS; PORT/TCP:
results|113.64.105.240|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
summary|113.64.105.240|OS: Unknown OS; PORT/TCP:
results|113.65.32.70|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
results|113.64.217.61|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">0000</font>"
summary|113.65.32.70|OS: Unknown OS; PORT/TCP:
summary|113.64.217.61|OS: Unknown OS; PORT/TCP:
results|113.66.237.60|ms-sql-s (1433/tcp)|HOLE|SQL-Server弱口令: "<font color="blue">sa</font>/<font color="red">[空口令]</font>"
整理成这样的格式:
61.146.0.86 sa ""
61.146.92.34 sa infox1eies2sps3was4!
......
113.64.217.61 sa 0000
如果是空口令就改成""
文本中绿颜色的也都去掉
请高手帮忙
作者: asnahu 时间: 2010-1-26 21:13
- sed "/results/!d; s/^[^|]*|\(.*\)|ms.*blue\x22>\(.*\)<\/font>/\1\t\2/g; s/<[^>]*>//g; s/\/\|\x22/\t/g; s/\[空口令\]/\x22\x22/g" 123.txt
复制代码
sed是第三方工具,在论坛搜索下载地址。另请自行优化代码。
[ 本帖最后由 asnahu 于 2010-1-26 21:18 编辑 ]
作者: lvsehuaxue 时间: 2011-5-14 20:52
来个不用sed的- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=2* delims=|" %%i in ('findstr /i /v "unknown" 123.txt') do (
- set "v=%%j"
- set "v=!v:*red"^>=!"
- set "v=!v:</font>"=!"
- if "!v:~,1!" equ "[" (echo %%i sa "") else echo %%i sa !v!
- )
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |