Saving Output
The output of a command-line program usually prints out in the Command Prompt window. You can save output by redirecting it into a file, using the > character. For example, the command
dir >listing.txt
lists the files in the current directory, and stores the results in the file listing.txt. You could then type notepad listing.txt to view the results. By itself, > creates a new file or replaces an existing file. You can tack output onto the end of (append to) a file using >>, as in this example:
dir c:\windows >>listing.txt
You can also send the output of one program to another program using | (the pipe character), as in
dir c:\windows | findstr /i setup
which lists the contents of folder c:\windows and prints out only entries that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access