Please help me how to use command as "command < file.txt" I don't know this command is used like. Give me a few examples. Thanks!
-
1There's some examples here! More examples here too.Dave Chen– Dave Chen2016-09-21 18:12:55 +00:00Commented Sep 21, 2016 at 18:12
-
Please read the entire tour page and learn how this site works! This is not a tutorial site, it is a community for asking and answering questions specific to programming.aschipfl– aschipfl2016-09-21 18:58:29 +00:00Commented Sep 21, 2016 at 18:58
2 Answers
command.exe < file.txt
That command would redirect the contents of file.txt to command.exe.
For example, if file.txt contained hello world, then set /p var=<file.txt would result with the contents of file.txt to be stored to %var%.
A complete batch file script utilising command redirection would be:
@echo off
echo hello 1234 > doc.txt
set /p contents = < doc.txt
echo The contents of "doc.txt"="%contents%"
pause
exit
Here are some links that further explain command redirection:
http://robvanderwoude.com/battech_redirection.php
http://ss64.com/nt/syntax-redirection.html
Comments
http://www.robvanderwoude.com/battech_redirection.php Visit the above link to know more about redirecting output from CMD to text files