Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As an example, I would like the following commands to put a dir listing with all subdirectories to StdOut

copy con test
dir `test`

So, after lines one and two, there's a file in the current directory called test containing /s. Line three doesn't work, of course, but I would like the result to be the same as

dir /s

. Perhaps a better for line 3 is

echo `test`

where I hope the result is

share|improve this question
up vote 0 down vote accepted

Backticks do not work the same in cmd as bash. You may be able to play around with type which is roughly equivalent to cat. Redirection isn't a high point for cmd, but the following may work[ish] for what I think you're asking:


Replace % with %% if this will be run from a batch file instead of the command line.

share|improve this answer
Yikes, that's a terrible answer. Unfortunately, it looks like you're right. :( – Limited Atonement Oct 23 '10 at 20:29
@Limited Sorry for the terrible answer. What exactly are you trying to accomplish with this? Are you building a cmd script to accept user input or something? If you wish to expand your question, I may be able to provide a better answer. – jscott Oct 23 '10 at 22:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.