Reputation: 13
i have log_prof_info_xxx random number xxx.txt
file (this file creation be last date and time)
this file in line is h ttp://ipadres:DIGIT(port)/live/path_DIGIT
( digit is only number but variable)
I want to find this line in that file and save it to an external file ?
example: log_prof_info_809809808.txt content is
h ttp://234.56.78:68912/live/osidosi_89797987
i tried code and not work :(
for /f "tokens=*" %%A in ("findstr "h ttp://234.56.78:[0-9]/live/osidosi_[0-9]" log_prof_info_809809808.txt") do ECHO %%A>>extractedline.txt
Upvotes: 0
Views: 72
Reputation: 80033
findstr /r /i /c:"h ttp://234.56.78:[0-9]*/live/osidosi_[0-9]*" log_prof_info_809809808.txt>extractedline.txt
worked fine for me - no need for the FOR
and note that >
above will creata a new output file containing the one line. This should be changed to >>
if you want to append to any existing content.
Upvotes: 1
Reputation: 41244
Try this line:
for /f "delims=" %%A in (' findstr "h ttp:\/\/234.56.78:[0-9]\/live\/osidosi_[0-9]" "log_prof_info_809809808.txt" ') do >>extractedline.txt ECHO %%A
Upvotes: 0
Reputation: 56190
for /?
says:
FOR /F ["Options"] %variable IN ('command') DO command[Parameter]
Note the single quotues '
.
put the command in single quotes instead of double quotes.
And: you forgot the *
after [0-9]
two times (repetition of previous char)
for /f "tokens=*" %%A in ('findstr "h ttp://234.56.78:[0-9]*/live/osidosi_[0-9]*" log_prof_info_809809808.txt') do ECHO %%A>>extractedline.txt
(there is a space in h ttp
- I assume, you are aware of that)
Upvotes: 1