1

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

copy con test
/s^Z
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

/s

1 Answer 1

0

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:

COPY CON TEST
/S^Z
FOR /F %A IN ('TYPE TEST') DO ( DIR %A )

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

2
  • Yikes, that's a terrible answer. Unfortunately, it looks like you're right. :( Commented Oct 23, 2010 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
    Commented Oct 23, 2010 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .