here is the logfile:
- SESSIONNAME USERNAME ID STATE TYPE DEVICE
>services 0 Disc
0123 18 Disc
console 19 Conn
rdp-tcp 65536 Listen
the specific word i want to show from the above log file is: 0123.
im using the word "disc" to find this specific word,
problem is i have "disc" twice in the log file, therefore it refers to the 1st "disc" and then i get "0",
if i delete manually the 1st "disc" from the log file, then its works (because now i have only 1 disc word).
i know i can use the number "18" instead "disc" to show the word i want, but "18" is a value that changed all time and "disc" is not.
so i thought how can i refer it to the 2nd "disc" to read the word i want ?
the code:
Code: Select all
log = c:\1.log
FileRead,log_file,%log%
log_filecsv = % RegExReplace(log_file, a_space "{2,}","`,")
Loop,Parse, log_filecsv, `n
{
line = %A_LoopField%
IfInString,line,disc
{
StringSplit,line,line,`,
break
}
}
MsgBox, %line2%
Thanks in advance!