0

When using Windows 10 command prompt, i know i can log the results to file by doing this :

dir c:\ > results.txt

But problem is, doing this , the results are NOT displayed on the screen.

Is there a way to use both ways at the same time ? I want the results to be displayed in real time AND log to file.

spikey_richie
  • 8,367
  • 2
  • 25
  • 42
delphirules
  • 561
  • 3
  • 10
  • 20
  • CMD is quite simple minded. Run CMD twice or invest in Power Shell programming. – John May 16 '22 at 14:40
  • What you are probably looking for is the UNIX `tail` command. [The UnxUtils](https://sourceforge.net/projects/unxutils/) package contains this command. As @John points out, powershell can do this out of the box but if you are looking to do what you are already doing without re-writing and re-learning, this is probably what you are looking for. – Señor CMasMas May 16 '22 at 14:48

2 Answers2

1

Its possible to first write it to the textfile and then displaying it by using the following command:

dir > a.txt | type a.txt

It may have problems including the first few lines. If you need those too, you can use:

dir > a.txt & type a.txt

The only downside is that if the dir command takes a long time, its going to take a while before you see the output.

If dir is really long and you want the output to take place at the same time, powershell is a better tool in that case. Keep in mind, that if you do display the output and log it at the same time, the displaying will cause a slowdown as well.

LPChip
  • 59,229
  • 10
  • 98
  • 140
0

Your simplest and (in my opinion) best option on a Windows machine is to use Baretail, and tail the log file.

spikey_richie
  • 8,367
  • 2
  • 25
  • 42