I need an equivalent of the Unix head
command (display the first N lines of the output). This is what I'm using currently:
tasklist | find /N " " | findstr /r \[[0-9]\]
The above code displays the first 10 lines of tasklist
's output. find /N " "
prepends a line number to the start of each line while findstr /r \[[0-9]\]
extracts the first 10 lines using regex.
Above code works, but I need to specify any range. Due to the fact that regular expressions are not implemented according to the standards in Windows, I can't get anything else to work.
How can I extract arbitrary lines from a cmd output? It is important to do this with a one-liner. No scripts!