I need to display the first N lines of the output of a command (any command). In other words, I esentially want an equivalent of the Unix "head" command. After discovering a few tricks from some other user (sorry don't remember who it was), I came up with this:
tasklist | find /N " " | findstr /r \[[0-9]\]
In the example above, the command processor display the first 10 lines of the tasklist command output.
find /N " "
adds the line number at the beginning of each line.
findstr /r \[[0-9]\]
extracts the first 10 lines using a regular expression.
Now, I would like to be able to specify any range, but 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 the first 20 lines, for example? It is important to do this with a one-liner. No scripts!