标题: [文本处理] 批处理如何替换这个txt里空格? [打印本页]
作者: uuu888s 时间: 2011-11-30 15:44 标题: 批处理如何替换这个txt里空格?
现有1.txt如下- (Request-Line) GET /ip.php HTTP/1.1
- Host www.socks-5.com
- User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
- Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Language en-us
- Accept-Encoding gzip,deflate
- Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
- Keep-Alive 300
- Connection keep-alive
- Cookie cookietest_time=Wednesday+30th+of+November+2011+03-15-19+PM
复制代码
编写bat生成如下格式的txt 并把生成的txt内容存在内存粘贴板里 以便粘贴(2个txt区别在于去掉1.txt第一行,余下每行第一个词后的空格改为:加空格)- Host: www.socks-5.com
- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Language: en-us
- Accept-Encoding: gzip,deflate
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
- Keep-Alive: 300
- Connection: keep-alive
- Cookie: cookietest_time=Wednesday+30th+of+November+2011+03-15-19+PM
复制代码
作者: szjwxn 时间: 2011-11-30 18:22
看看这样是不是符合要求:- @echo off
- setlocal enabledelayedexpansion
- color 1a
- for /f "skip=1 tokens=1,2* delims= " %%a in (1.txt) do (
- echo %%a: %%b %%c>>2.txt
- )
- pause>nul
复制代码
作者: xudaweb 时间: 2011-11-30 18:30
- @echo off
-
- for /f "skip=1 tokens=1* delims= " %%i in (1.txt) do echo %%i: %%j>>2.txt
复制代码
作者: uuu888s 时间: 2011-11-30 19:04
本帖最后由 uuu888s 于 2011-11-30 19:19 编辑
ok!保存在粘贴板 有代码吗
作者: lvsehuaxue 时间: 2011-11-30 19:49
- echo off
- (for /f "skip=1 tokens=1*" %%i in (1.txt) do echo %%i: %%j)>2.txt
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |