0

I am trying to get the last 10 lines of a file using , .exe.

I am able to get the number of lines in the file using the for loop/delim. The problem is I need to subtract 10 from %G and pass that to the chained more command. But the variable last10 is either not getting set or not passing to the more command.

for /f "tokens=3 delims=: " %G IN ('find /v /c "" file.log') DO (set /a "last10=%G-10" & more file.log +%last10%)

How can I get the variable last10 correctly in the more command?

Compo
  • 36,585
  • 5
  • 27
  • 39
LAX_DEV
  • 2,111
  • 3
  • 19
  • 29
  • classic [delayed expansion](https://stackoverflow.com/a/30284028/2152082) failure. Any specific reason to do it on command line instead of a short batch script? – Stephan Jul 14 '19 at 10:10
  • I need to call this command from node.js exec call. I am not allowed to create a batch file. How can I fix this? – LAX_DEV Jul 14 '19 at 10:22
  • Got it. I added cmd /V:ON /C before the set and it worked. Thank you! – LAX_DEV Jul 14 '19 at 10:28

0 Answers0