DOS: saving results to file and print to screen

CanOWorms

Lifer
Jul 3, 2001
12,404
2
0
I'm trying to have a command at the dos prompt display to the screen as well as save to a file at the same time. Is it possible to do this?

I can do either one or the other. For example:

Display to screen: dir
Save to a file (but doesn't display to the screen): dir >c:\dir.txt

Is there a way to combine both?
 

Smilin

Diamond Member
Mar 4, 2002
7,357
0
0
not that I'm aware of. you could kludge it and make it run twice...

dir && dir > dir.txt

or

dir > dir.txt && type dir.txt

2nd mode would probably be a bit faster for large directories.
 

kd7fhd

Senior member
Dec 5, 2000
339
0
76
Smilin has the right idea but don't use ampersands. Use the Pipe instead.

dir > dir.txt|dir
 

pallejr

Senior member
Apr 8, 2007
216
0
0
the pipe is used to when you want to use output from one command as input to another. So the ampersand is the correct one