我有一包含数字的日志文件A.LOG,想通过批处理实现在产生的日志上增加数字序列
比如日志内容如下:
9/9 11:20:00.234 7cc Srv: StarWind Alcohol Edition iSCSI Target v3.2.3 (Build 20070527, Win32, Alcohol Edition)
9/9 11:20:00.234 7cc Srv: Built May 29 2007 00:57:30
9/9 11:20:00.234 7cc Srv: System CPU count: 1
9/9 11:20:00.234 7cc Srv: Unlimited number of client hosts allowed.
9/9 11:20:00.296 7cc Srv: Special build (plugins are disabled).
9/9 11:20:00.328 7cc Srv: Config file: 'StarWindLite.cfg'
9/9 11:20:01.718 7cc conf: 'LogLevel' = '1'
9/9 11:20:01.718 7cc conf: 'LogMask' = '0x8fffffff'
9/9 11:20:01.718 7cc conf: 'Port' = '3260'
9/9 11:20:01.718 7cc conf: 'Interface' = '0.0.0.0'
9/9 11:20:01.718 7cc conf: 'Login' = 'test'
9/9 11:20:01.718 7cc conf: 'Password' = '##CY9rzUYh03PK3k6DJie09g=='
9/9 11:20:01.718 7cc conf: 'MinBufferSize' = '65536'
9/9 11:20:01.718 7cc conf: 'AlignmentMask' = '0x0000'
9/9 11:20:01.718 7cc conf: 'MaxPendingRequests' = '64'
9/9 11:20:01.718 7cc conf: 'DefTargetName' = 'iqn.2003-06.com.rocketdivision.swl:$(host).$(symid)'
9/9 11:20:01.718 7cc conf: 'AllowOnlyRecordableCd' = 'no'
9/9 11:20:01.718 7cc conf: Variable 'LogLevel' is set to '1'.
9/9 11:20:01.718 7cc conf: Variable 'LogMask' is set to '0x8fffffff'.
9/9 11:20:01.718 7cc conf: Variable 'Port' is set to '3260'.
9/9 11:20:01.718 7cc conf: Variable 'Interface' is set to '0.0.0.0'.
9/9 11:20:01.718 7cc conf: Variable 'Login' is set to 'test'.
9/9 11:20:01.718 7cc conf: Variable 'Password' is set
通过批处理实现每增加一个日志前运行批处理可自己在日志上加序号,达到以下效果:
01
9/9 11:20:00.234 7cc Srv: StarWind Alcohol Edition iSCSI Target v3.2.3 (Build 20070527, Win32, Alcohol Edition)
9/9 11:20:00.234 7cc Srv: Built May 29 2007 00:57:30
9/9 11:20:00.234 7cc Srv: System CPU count: 1
9/9 11:20:00.234 7cc Srv: Unlimited number of client hosts allowed.
02
9/9 11:20:00.296 7cc Srv: Special build (plugins are disabled).
9/9 11:20:00.328 7cc Srv: Config file: 'StarWindLite.cfg'
9/9 11:20:01.718 7cc conf: 'LogLevel' = '1'
9/9 11:20:01.718 7cc conf: 'LogMask' = '0x8fffffff'
9/9 11:20:01.718 7cc conf: 'Port' = '3260'
9/9 11:20:01.718 7cc conf: 'Interface' = '0.0.0.0'
03
9/9 11:20:01.718 7cc conf: 'Login' = 'test'
9/9 11:20:01.718 7cc conf: 'Password' = '##CY9rzUYh03PK3k6DJie09g=='
9/9 11:20:01.718 7cc conf: 'MinBufferSize' = '65536'
9/9 11:20:01.718 7cc conf: 'AlignmentMask' = '0x0000'
9/9 11:20:01.718 7cc conf: 'MaxPendingRequests' = '64'
04
9/9 11:20:01.718 7cc conf: 'DefTargetName' = 'iqn.2003-06.com.rocketdivision.swl:$(host).$(symid)'
9/9 11:20:01.718 7cc conf: 'AllowOnlyRecordableCd' = 'no'
9/9 11:20:01.718 7cc conf: Variable 'LogLevel' is set to '1'.
9/9 11:20:01.718 7cc conf: Variable 'LogMask' is set to '0x8fffffff'.
05
9/9 11:20:01.718 7cc conf: Variable 'Port' is set to '3260'.
9/9 11:20:01.718 7cc conf: Variable 'Interface' is set to '0.0.0.0'.
9/9 11:20:01.718 7cc conf: Variable 'Login' is set to 'test'.
9/9 11:20:01.718 7cc conf: Variable 'Password' is set
以后自己每增加一次日志,通过批处理判断在文件中前面的序列号再追加新的序号!谢谢各位!
比如日志内容如下:
9/9 11:20:00.234 7cc Srv: StarWind Alcohol Edition iSCSI Target v3.2.3 (Build 20070527, Win32, Alcohol Edition)
9/9 11:20:00.234 7cc Srv: Built May 29 2007 00:57:30
9/9 11:20:00.234 7cc Srv: System CPU count: 1
9/9 11:20:00.234 7cc Srv: Unlimited number of client hosts allowed.
9/9 11:20:00.296 7cc Srv: Special build (plugins are disabled).
9/9 11:20:00.328 7cc Srv: Config file: 'StarWindLite.cfg'
9/9 11:20:01.718 7cc conf: 'LogLevel' = '1'
9/9 11:20:01.718 7cc conf: 'LogMask' = '0x8fffffff'
9/9 11:20:01.718 7cc conf: 'Port' = '3260'
9/9 11:20:01.718 7cc conf: 'Interface' = '0.0.0.0'
9/9 11:20:01.718 7cc conf: 'Login' = 'test'
9/9 11:20:01.718 7cc conf: 'Password' = '##CY9rzUYh03PK3k6DJie09g=='
9/9 11:20:01.718 7cc conf: 'MinBufferSize' = '65536'
9/9 11:20:01.718 7cc conf: 'AlignmentMask' = '0x0000'
9/9 11:20:01.718 7cc conf: 'MaxPendingRequests' = '64'
9/9 11:20:01.718 7cc conf: 'DefTargetName' = 'iqn.2003-06.com.rocketdivision.swl:$(host).$(symid)'
9/9 11:20:01.718 7cc conf: 'AllowOnlyRecordableCd' = 'no'
9/9 11:20:01.718 7cc conf: Variable 'LogLevel' is set to '1'.
9/9 11:20:01.718 7cc conf: Variable 'LogMask' is set to '0x8fffffff'.
9/9 11:20:01.718 7cc conf: Variable 'Port' is set to '3260'.
9/9 11:20:01.718 7cc conf: Variable 'Interface' is set to '0.0.0.0'.
9/9 11:20:01.718 7cc conf: Variable 'Login' is set to 'test'.
9/9 11:20:01.718 7cc conf: Variable 'Password' is set
通过批处理实现每增加一个日志前运行批处理可自己在日志上加序号,达到以下效果:
01
9/9 11:20:00.234 7cc Srv: StarWind Alcohol Edition iSCSI Target v3.2.3 (Build 20070527, Win32, Alcohol Edition)
9/9 11:20:00.234 7cc Srv: Built May 29 2007 00:57:30
9/9 11:20:00.234 7cc Srv: System CPU count: 1
9/9 11:20:00.234 7cc Srv: Unlimited number of client hosts allowed.
02
9/9 11:20:00.296 7cc Srv: Special build (plugins are disabled).
9/9 11:20:00.328 7cc Srv: Config file: 'StarWindLite.cfg'
9/9 11:20:01.718 7cc conf: 'LogLevel' = '1'
9/9 11:20:01.718 7cc conf: 'LogMask' = '0x8fffffff'
9/9 11:20:01.718 7cc conf: 'Port' = '3260'
9/9 11:20:01.718 7cc conf: 'Interface' = '0.0.0.0'
03
9/9 11:20:01.718 7cc conf: 'Login' = 'test'
9/9 11:20:01.718 7cc conf: 'Password' = '##CY9rzUYh03PK3k6DJie09g=='
9/9 11:20:01.718 7cc conf: 'MinBufferSize' = '65536'
9/9 11:20:01.718 7cc conf: 'AlignmentMask' = '0x0000'
9/9 11:20:01.718 7cc conf: 'MaxPendingRequests' = '64'
04
9/9 11:20:01.718 7cc conf: 'DefTargetName' = 'iqn.2003-06.com.rocketdivision.swl:$(host).$(symid)'
9/9 11:20:01.718 7cc conf: 'AllowOnlyRecordableCd' = 'no'
9/9 11:20:01.718 7cc conf: Variable 'LogLevel' is set to '1'.
9/9 11:20:01.718 7cc conf: Variable 'LogMask' is set to '0x8fffffff'.
05
9/9 11:20:01.718 7cc conf: Variable 'Port' is set to '3260'.
9/9 11:20:01.718 7cc conf: Variable 'Interface' is set to '0.0.0.0'.
9/9 11:20:01.718 7cc conf: Variable 'Login' is set to 'test'.
9/9 11:20:01.718 7cc conf: Variable 'Password' is set
以后自己每增加一次日志,通过批处理判断在文件中前面的序列号再追加新的序号!谢谢各位!
