A Better Way to View Shell Command Output

I’m a command prompt guy.  If there is a way to do something with the keyboard, then by golly, that’s how I’m going to do it.  But sometimes you’ll want to use a command whose options and formatting aren’t obvious, and when you type the command to view the command’s usage (usually by typing command /?, command -h, or command –help), black and white letters go flying by like a newspaper in a Blendtec ad.

Linux users can read command documentation via the man command which provides detailed usage instructions in a way that’s easy to read and navigate.  We Windows admins don’t have such a luxury, but you can mimic it.

Piping Output to More

One way to view the output of a command when it’s longer than a single screen is by piping the output to the more command like this:

command | more

For example if I want to view the help page for the icacls command:

icacls.exe /? | more

This method works, but what if you want to save the command’s output for use later?

Redirecting Output to a File

Another option is to send the command’s output to a file. This can be done using the redirection operator “>”

command > output.txt

Using the same command from above, we’ll save the command usage page for icacls.exe to a file called icacls_help.txt:

icacls /? > icacles_help.txt

If we want to be really fancy, we can combine the ideas of redirection and piping and view the help page immediately in notepad:

icacls /? > icacls_help.txt | notepad icacls_help.txt