1

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!

2
  • 1
    There's some examples here! More examples here too. Commented 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. Commented Sep 21, 2016 at 18:58

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

http://www.robvanderwoude.com/battech_redirection.php Visit the above link to know more about redirecting output from CMD to text files

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.