I am very close to my answer, but I think that to find it I think. I am using the findstr function in a batch file so that now a whole directory can be narrowed to just one file.
cd ... findstr / s / m "desktop" * class.asasm & gt; Results1 .txt findstr / m /f:results1.txt "product" * class.asasm & gt; Results2.txt findstr / n /f:results2.txt "capabilities" * class.asasm & gt; Task 1: Finding it in a way to search backwards for a fourth string from the I foundstr line number was found on the third line I am writing an application with Visual Studio in VBnet and I have a hard time knowing how to complete this process. I am currently working better with the application running batch files within the application.
The correct solution is to find an instrument that does this properly does not batch / CMD.
Here is a script that tells you the line number of the 3rd and 4th matches. It's probably not really what you want, but it's a demonstration of how one can effectively work with line numbers.
SETLOCAL ENABLEDELAYEDEXPANSION set file off @ECHO = TestFile.txt set _LINENO = 1 set _MATCHNO = 0 set _THIRDLINENUM = set _FOURTHLINENUM = for / F %% l (% file%) DO (ECHO %% l | findstr "target"% _TMP% & gt; NUL IF NOT ERRORLEVEL 1 (set / A _MATCHNO = _ MATCHNO! +1 if _MATCHNO == 3 set _THIRDLINENUM = _ lineno if _MATCHNO == 4 set _FOURTHLINENUM = _ lineno ) Set / A _LINENO = _ lineno +1) @ECHO% _THIRDLINENUM%: !!!!!!!!% _FOURTHLINENUM% What's in TestFile.txt here
abcdefg bcdefgh target 1 cdefghi defghij fghijkl target 2 gjjklm hijklmn ijklmno jklmnop klmnopq lmnopqr mnopqrs target 3 nopqrst target 4 opcrstu pqrstuv qrstuvw rstuvwx stuvwxy tuvwxyz using batch Insist on the field, then CMD (and I sometimes have nothing else available), and you need to get the text on the line #N (otherwise, the head and tail will just do fine), you can do the same Create a loop, but change the code from FINDSTR to the end of the IF statement, compared to _LINENO with some other variables, if it is between two values, I do not know if IF supports logical operators, IF Statement Finalists may be the nest, like
IF! _LINENO! GQ% START_LINE%! _LINENO! LEQ% END_LINE% @ECHO %% l
No comments:
Post a Comment