下面是一个log.txt文件
C:\NTtest\logcompare>net use s: /delete /y
C:\NTtest\logcompare>net use s: [url=file://\\10.20.25.115\nttest]\\10.20.25.115\nttest[/url]
The command completed successfully.
C:\NTtest\logcompare>copy s:\cshdpm5.txt s:\logcompare\cshdpm5.txt
1 file(s) copied.
C:\NTtest\logcompare>del s:\logcompare\cshdpm5.txt
C:\NTtest\logcompare>s:
S:\>RTOPCB /S dwn.DTF
IBM iSeries Access for Windows
Version 5 Release 3 Level 0
Transfer data from iSeries
(C) Copyright IBM Corporation and Others 1984, 2003. All rights reserved.
U.S. Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
Licensed Materials - Property of IBM
Transfer file: dwn.DTF
Receive completed successfully.
Rows transferred: 41
S:\>rfrompcb /s upload.dtt
IBM iSeries Access for Windows
Version 5 Release 3 Level 0
Transfer data to iSeries
(C) Copyright IBM Corporation and Others 1984, 2003. All rights reserved.
U.S. Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
Licensed Materials - Property of IBM
Transfer file: upload.dtt
Send completed successfully.
Rows transferred: 41
我想要在蓝色字体的2行冒号以后的数字不显示,其他所有的输出到comparelog中去,写了如下命令:
for /f "delims=: tokens=17" %%i in (log.txt) do echo %%i > comparelog.txt
但是没有comparelog文件生成,是我命令用法不对吗?谢谢!
我倒是有另一种办法能达到同样目的
setlocal ENABLEDELAYEDEXPANSION
set STR1=Rows transferred: 41
SET STR2=Rows transferred:
for /f "tokens=* delims=" %%a in (log.txt) do (
set n=%%a
set n=!n:%STR1%=%STR2%!
echo !n!>>comparelog
)作者: leon 时间: 2009-4-2 10:00
谢谢!学习下!作者: Lumiere 时间: 2009-4-2 11:21
鉴于文本中有数字41的的行就是蓝色字体部分的两行,所以用字符串替换就可以。
setlocal enabledelayedexpansion
for /f "delims=" %%a in (log.txt) do set var=%%a&echo !var:41=!>>logcompare.txt
pause