中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 17:33
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS学习入门 & 精彩文章 (教学室) » Who knows the usage of the redirection commands < and << in Dos?
Printable Version  2,127 / 9
Floor1 qingteng1983 Posted 2006-11-24 09:51
新手上路 Posts 2 Credits 6
Although the materials all say that it can read things from files, there are no examples. Now I have a text file with only one number. I want to read it out and assign it to a variable. How to do it? I tried set var=<a.txt, which doesn't work. Hope to get some ideas or materials!
Floor2 bailang3106 Posted 2008-09-19 14:17
初级用户 Posts 19 Credits 36
Help to top up. I also want to know how to do it. Most of the things in the forum are >.
Floor3 wwmmc Posted 2008-11-27 16:15
初级用户 Posts 62 Credits 35
">" and ">>" are both output redirections. However, ">>" appends the content to be output to the end of the document. For example:

@echo off
dir > d:\1.txt
pause

@echo off
dir >> d:\1.txt
pause

You can see the difference by having a look.
Floor4 HAT Posted 2008-11-27 17:22
版主 Posts 5,017 Credits 9,023
It is suggested to ask questions in the Batch Processing Room
Floor5 DOSforever Posted 2008-11-27 19:59
金牌会员 Posts 2,239 Credits 4,639
Hehe, I don't think this is only related to batch processing. Redirecting command lines can also be used.
Floor6 alchemist Posted 2008-11-28 21:39
高级用户 Posts 193 Credits 652
< is input redirection, providing the internal response of the software. The content of dir.txt has only one byte which is D. For example, xcopy adir bdir < dir.txt. When prompted "Does 2 specify a file name or directory name on the target (F = File, D = directory)", the answer "D" will automatically become the answer and the copy continues.
Floor7 alchemist Posted 2008-11-28 21:43
高级用户 Posts 193 Credits 652
Originally posted by wwmmc at 2008-11-27 16:15:
">" ">>"
Both are output redirections
However, ">>" appends the content to be output to the end of the document
For example:
@echo off
dir > d:\1.txt
pause

@echo off
...


There are several other uses for the output redirection ">", such as
dir > PRN
This sends the content output by dir directly to the printer (only printers using the LPT port)
And the following
pkunzip aa.zip c:\tools > nul
This means no decompression information is output during the decompression of aa.zip
Floor8 Qtwdftxvt Posted 2008-11-28 21:56
初级用户 Posts 101 Credits 190
">" is output; ">>" is append; "<" is input.
Floor9 earth123xinyuan Posted 2009-02-10 13:45
社区乞丐 Posts 25 Credits -46 From 内蒙
Hope there are some experts to give a few examples
Floor10 pujihong123 Posted 2009-02-12 22:35
初级用户 Posts 27 Credits 47 From 甘肃. 武威
Take it back and Google it a bit!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023