I would think that Powershell would be a better solution. Use Get-ChildItem to get file objects and then use Get-Content to read the file content. A For-Each loop can then process each line to look to see if the record should be processed. Then use the .SubString method to pick off the data at certain positions.
Help with findstr
Hi
I'm looking for some guidance in regard to using findstr (i'm not too tech savvy, and i don't have admin rights to the PC - if that is going to restrict what i am trying to do).
I have to identify a specific text string in a data file (a *.flt file) within a specific byte location, and then return a string from another specific byte location.
i.e
Within my data exists "01" within byte reference <101-102>, when the line starts with "001" (this could also contain other variables, but i am just interested in where the value is "01"
My data extract contains different lines of data, all starting with repeating numbers -
i.e line 1 = "001", line 2 = "300", then line 3 might rettur to "001" again.
When i get a "hit", i would want a specific byte reference to be returned.
i.e <108-114>
Is this possible by using FINDSTR?
i've got as far as listing the values i want to find in a text file, and then listing the files i want to search in another text file (like the example on the MS website)
Findstr /g:stringlist.txt /f:filename.txt >results.out
I guess the question i am trying to ask is - is it possible to define what is returned in the results.
I've added "/n" before results which is pretty good, it returns the line number, but this isn't specific enough for me - especially when i have over 1,000 variables to locate.
Thanks in advance for any tips/help. Appreciate i might be asking way too much from Findstr, and it might be better suited to an SQL query (which i wouldn't have a clue about).
Many thanks
Stu
o
2 answers
Sort by: Most helpful
-
-
Rita Han - MSFT 2,166 Reputation points
2020-08-06T06:56:52.767+00:00 Hello,
where the value is "01"
"/o" parameter can prints character offset before each matching line.
Take this as an example:
Result:
As other specific requirements you may check PowerShell solution or write an application to get exactly what you want.
Thank you!