user94945
user94945

Reputation: 31

tokenize string in batch script

I have one file contianing below line :

MO Attribute
Value ================================================================================================================= 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 ================================================================================================================= Total: 2 MOs

MGW02NN> get . maxOutgoingStream

141202-11:53:55 10.76.128.12 10.0s MGW_NODE_MODEL_C_1_76 stopfile=/tmp/22309 ================================================================================================================= MO Attribute
Value ================================================================================================================= 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 ================================================================================================================= Total: 2 MOs

i am searching line wich matches to the string maxOutgoingStream ,i am able to do it i am trying 2 token of line maxOutgoingStream 17 to store in a array ,but i am not able to store both tokens i am able to store only one token either maxOutgoingStream or 17.

i tried with the following code:

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"
)

please tell me solution how can store both together in an array as maxOutgoingStream 17.

Upvotes: 1

Views: 290

Answers (1)

Stephan
Stephan

Reputation: 56188

to use more tokens, just increase the %% variable:

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

Upvotes: 1

Related Questions