On Unix I would do something like:
cat > file.txt
How can I do this on the Windows command prompt or batch file?
EDIT: Basically, I am looking for the functionality of cat
with no arguments (it reads from stdin and spits it back out to stdout).
Standard input:
Batch file:
I think
more.exe
might be what you are looking for.It can take input both from the console:
Or piped in from another file, which
TYPE CON
doesn't handle:(
more
seems to append a newline to your file and expands tabs, so don't use it on binary data!)TYPE CON
CON is the MS-DOS device for console input. You can redirect to a file as follows:
TYPE CON>output.txt
To terminate, hit Ctrl + C or Ctrl + Z, Enter (Ctrl + Z = EOF).
If all you want is to read stdin and write what you read to stdout, then FINDSTR may work, depending on how you use it.
FINDSTR will output an exact binary image of the input as long as the input is specified as a single file name at the end of the argument list.
Pipes or redirection may also work, depending on the content of the input:
The output will be corrupted if any of the following occur while using redirected or piped input with FINDSTR:
FINDSTR will not work if multiple input files are specified because in that case the name of the file will be used as a prefix to each line of output.
FINDSTR also differs from cat in that it cannot read from both stdin and a named file.
See What are the undocumented features and limitations of the Windows FINDSTR command? for more info.