在批处理脚本中标记字符串

时间:2014-12-18 06:46:12

标签: batch-file

我有一个文件在行下方:

  

MO属性
  值   ================================================== ================================================== ============= Sctp = CTRL-2_10.76.32.6_10.76.32.69
  maxIncomingStream 17 Sctp = CTRL-5_10.76.32.7_10.76.32.70
  maxIncomingStream 17   ================================================== ================================================== =============总计:2 MOs

     

MGW02NN>得到。 maxOutgoingStream

     

141202-11:53:55 10.76.128.12 10.0s MGW_NODE_MODEL_C_1_76   stopfile = / TMP / 22309   ================================================== ================================================== ============= MO属性
  值   ================================================== ================================================== ============= Sctp = CTRL-2_10.76.32.6_10.76.32.69
  maxOutgoingStream 17 Sctp = CTRL-5_10.76.32.7_10.76.32.70
  maxOutgoingStream 17   ================================================== ================================================== =============总计:2 MOs

我正在搜索与字符串maxOutgoingStream匹配的行,我能够这样做我正在尝试将2行令牌maxOutgoingStream 17存储在一个数组中,但我无法存储两个令牌我只能存储一个令牌是maxOutgoingStream或17。

我尝试使用以下代码:

for /F "tokens=2,3 delims= " %%a in ('findstr "associationMaxRtx maxIncomingStream maxOutgoingStream initialAdRecWin maxUserdataSize mBuffer nThreshold PathMaxRtx maxInitialRtrAtt minimumRto maximumRto initialRto rtoAlphaIndex tSack" C:\Users\ephajin\logs.txt') do (
    set /A count+=1
     set "array[!count!]=%%a"
)

请告诉我解决方案如何将两者一起存储在一个数组中作为maxOutgoingStream 17。

1 个答案:

答案 0 :(得分:1)

要使用更多令牌,只需增加%%变量:

for /f "tokens=2,3,5,9 delims= " %%a in (...) do echo 2=%%a, 3=%%b, 5=%%c, 9=%%d