标题: [文本处理] 批处理怎样从不规则文本内容里面获取IP? [打印本页]
作者: AGhuawei 时间: 2022-12-8 21:56 标题: 批处理怎样从不规则文本内容里面获取IP?
open tcp 80 116.62.126.137 1670480212
open tcp 80 112.126.254.212 1670480123
open tcp 80 121.42.124.114 16704801233
open tcp 80 116.196.73.5 1670480122
open tcp 80 52.198.128.19 1670480221
open tcp 80 52.194.44.14 1670480232
open tcp 80 54.64.124.189 1670480123
open tcp 80 52.219.177.179 167048022
open tcp 80 52.199.76.104 1670480233
open tcp 80 121.41.118.242 1670480111
open tcp 80 52.69.237.72 1670480333
open tcp 80 52.199.129.85 1670480112
open tcp 80 52.68.220.120 1670480221
open tcp 80 115.146.7.190 1670480232
open tcp 80 52.69.237.160 1670480711
open tcp 80 52.194.112.142 1670480223
open tcp 80 52.199.42.212 1670480712
open tcp 80 54.249.169.109 167048032
open tcp 80 120.76.243.3 1670480232
open tcp 80 121.40.190.217 1670480211
作者: AGhuawei 时间: 2022-12-8 22:02 标题: 批处理怎样从不规则文本内容里面获取IP?
open tcp 80 154.91.104.7 1670480778
open tcp 80 156.244.67.27 1670480778
open tcp 80 202.88.30.132 1670480778
open tcp 80 65.9.35.225 1670480778
open tcp 80 54.68.39.79 1670480778
open tcp 80 153.121.41.94 1670480778
open tcp 80 154.210.18.215 1670480778
open tcp 80 108.179.193.166 1670480778
open tcp 80 54.165.223.229 1670480778
open tcp 80 40.74.83.53 1670480778
open tcp 80 54.68.39.120 1670480778
open tcp 80 150.60.10.220 1670480778
open tcp 80 156.235.220.182 1670480778
open tcp 80 153.126.209.166 1670480778
open tcp 80 52.218.24.172 1670480778
open tcp 80 5.9.122.219 1670480778
open tcp 80 47.98.31.201 1670480778
open tcp 80 23.63.39.45 1670480778
open tcp 80 139.129.228.71 1670480778
open tcp 80 103.154.31.93 1670480778
open tcp 80 51.159.52.140 1670480778
open tcp 80 47.98.236.84 1670480778
open tcp 80 2.20.109.101 1670480778
open tcp 80 101.200.61.33 1670480778
open tcp 80 106.14.165.42 1670480778
open tcp 80 54.92.208.166 1670480778
open tcp 80 154.91.239.228 1670480778
open tcp 80 52.216.229.198 1670480778
open tcp 80 18.178.40.23 1670480778
open tcp 80 3.113.253.158 1670480778
open tcp 80 47.98.202.132 1670480778
open tcp 80 38.54.159.131 1670480778
open tcp 80 52.207.25.60 1670480778
open tcp 80 18.178.142.155 1670480778
open tcp 80 23.223.239.69 1670480778
open tcp 80 106.13.216.35 1670480778
open tcp 80 13.113.97.134 1670480778
open tcp 80 47.96.115.124 1670480778
open tcp 80 18.181.22.48 1670480778
open tcp 80 47.115.112.209 1670480778
open tcp 80 13.113.233.173 1670480778
open tcp 80 31.220.111.89 1670480778
open tcp 80 47.98.183.118 1670480778
open tcp 80 47.93.85.76 1670480778
open tcp 80 52.216.109.253 1670480778
open tcp 80 52.216.143.237 1670480778
open tcp 80 122.17.166.68 1670480778
open tcp 80 54.68.158.113 1670480778
open tcp 80 34.226.225.122 1670480778
open tcp 80 206.2.150.89 1670480778
open tcp 80 206.2.218.54 1670480778
open tcp 80 156.244.134.147 1670480778
open tcp 80 2.16.229.26 1670480778
open tcp 80 2.16.58.198 1670480778
open tcp 80 156.254.134.227 1670480778
open tcp 80 38.165.91.24 1670480778
open tcp 80 52.216.178.106 1670480778
open tcp 80 149.248.199.122 1670480778
open tcp 80 47.104.129.229 1670480778
open tcp 80 156.234.17.14 1670480778
open tcp 80 47.103.216.7 1670480778
open tcp 80 106.13.250.137 1670480778
open tcp 80 47.106.197.132 1670480778
open tcp 80 164.88.53.5 1670480778
open tcp 80 156.244.32.88 1670480778
open tcp 80 13.114.189.50 1670480778
open tcp 80 23.13.191.152 1670480778
open tcp 80 18.228.28.119 1670480778
open tcp 80 106.75.19.245 1670480778
open tcp 80 217.160.46.98 1670480778
open tcp 80 52.0.18.34 1670480778
open tcp 80 219.94.159.66 1670480778
open tcp 80 52.59.125.75 1670480778
open tcp 80 47.52.221.221 1670480778
open tcp 80 154.210.2.45 1670480778
open tcp 80 164.88.19.100 1670480778
open tcp 80 151.101.230.46 1670480778
open tcp 80 156.244.32.52 1670480778
open tcp 80 13.113.206.192 1670480778
open tcp 80 23.161.240.119 1670480778
open tcp 80 149.248.217.124 1670480778
open tcp 80 219.118.71.36 1670480778
open tcp 80 158.199.215.201 1670480778
open tcp 80 210.60.141.225 1670480778
open tcp 80 47.74.34.120 1670480778
open tcp 80 156.244.134.154 1670480778
open tcp 80 217.160.182.178 1670480778
open tcp 80 104.22.79.254 1670480778
open tcp 80 104.71.162.4 1670480778
open tcp 80 39.106.87.138 1670480778
open tcp 80 104.16.82.108 1670480778
open tcp 80 39.108.188.223 1670480778
open tcp 80 77.55.156.148 1670480778
open tcp 80 218.40.200.156 1670480778
open tcp 80 39.96.174.241 1670480778
open tcp 80 47.74.85.93 1670480778
open tcp 80 223.29.61.210 1670480778
open tcp 80 35.209.234.168 1670480778
open tcp 80 211.233.108.163 1670480778
open tcp 80 39.96.4.86 1670480778
open tcp 80 103.204.111.4 1670480778
open tcp 80 31.192.214.170 1670480778
open tcp 80 43.135.77.217 1670480778
open tcp 80 54.36.126.16 1670480778
open tcp 80 23.223.103.63 1670480778
作者: pd1 时间: 2022-12-9 00:00
原文存在1.txt ANSI格式- @echo off
- (for /f "tokens=4 delims= " %%a in (1.txt) do (
- echo %%a
- ))>>result.txt
复制代码
作者: 77七 时间: 2022-12-9 03:27
- @echo off
- (for /f "tokens=4 delims= " %%i in (1.txt) do (
- echo %%i
- ))>2.txt
- pause
复制代码
作者: AGhuawei 时间: 2022-12-9 13:48
回复 3# pd1
谢谢你们,可以用,就是我的ip文本文件太大啦,处理就一直在那里不动了
我没别的,可以给你送一个谷歌邮箱带辅助邮箱那种表示感谢。
作者: AGhuawei 时间: 2022-12-9 13:48
回复 3# pd1
谢谢你们,可以用,就是我的ip文本文件太大啦,处理就一直在那里不动了
我没别的,可以给你送一个谷歌邮箱带辅助邮箱那种表示感谢。
作者: AGhuawei 时间: 2022-12-9 13:53
回复 4# 77七
谢谢你们,可以用,就是我的ip文本文件太大啦,处理就一直在那里不动了
我没别的,可以给你送一个谷歌邮箱带辅助邮箱那种表示感谢。
作者: Batcher 时间: 2022-12-9 14:10
回复 6# AGhuawei
原始txt文件多大?可以使用其它方法提升速度
作者: 77七 时间: 2022-12-9 14:16
回复 7# AGhuawei
谢谢你的好意,不过我用不到谷歌,你可以给需要的人。
作者: idwma 时间: 2022-12-9 21:17
- #@&cls&powershell "type '%~f0'|out-string|iex"&exit
-
- add-type @'
- using System;
- using System.IO;
- using System.Text;
- public static class test
- {
- public static void a(string i,string o)
- {
- using (FileStream fs = File.OpenWrite(o))
- {
- using (StreamReader sr = File.OpenText(i))
- {
- string s = "";
- while ((s = sr.ReadLine()) != null)
- {
- if(s.Length > 0)
- {
- //Console.WriteLine(s);
- Byte[] info =
- new UTF8Encoding(true).GetBytes(s.Split(' ')[3]+"\r\n");
- fs.Write(info, 0, info.Length);
- }
- }
- }
-
- }
- }
- }
- '@
- [test]::a('1.txt','2.txt')
复制代码
作者: hfxiang 时间: 2022-12-10 09:38
回复 6# AGhuawei
看主楼的文件,其规则性很强,如果文件太大,可考虑第3方工具gawk( http://bcn.bathome.net/tool/4.1.0/gawk.exe ),其效率会非常高,但其要求输入文件1.txt必须为ANSI编码格式- gawk "{print $4}" 1.txt>2.txt
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |