最短DOS批处理文件code获取设置为一个变量文件的第一行? [英] Shortest DOS batch file code to get first line of a file set to a variable?
问题描述
我要寻找,将得到一个文本文件的第一行,并将其设置为DOS / Windows中的DOS变量code可能的最短时间。
有很多这样的事情在其他线程在这个StackExchange网站的例子,但我的不可以寻找如何循环并显示文件中的所有行。我要的是刚刚的简单获取的第一行。
设置/对VAR =< TEXT.TXT
回声%VAR%
从引用:<一href=\"http://forums.techguy.org/software-development/551867-batch-file-read-line-text.html\">http://forums.techguy.org/software-development/551867-batch-file-read-line-text.html
具有讽刺意味的海报能拿到第一线,而是通过整个文件要循环!
I am looking for the shortest amount of DOS code possible that will get the first line of a text file and set it to a variable in DOS/Windows.
There are lots of examples of this kind of thing in other threads on this StackExchange site but I am not looking for how to loop through and display all lines in a file. What I want is to just simply get the first line.
set /p var= <Text.txt
echo %var%
Referenced from: http://forums.techguy.org/software-development/551867-batch-file-read-line-text.html Ironically the poster is able to get the first line but wanted to loop through the whole file!
这篇关于最短DOS批处理文件code获取设置为一个变量文件的第一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!