China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 13:48
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to set the content in the file as a variable?? Urgent, waiting online View 1,802 Replies 2
Original Poster Posted 2010-12-28 18:45 ·  中国 广西 百色 电信
初级用户
Credits 34
Posts 30
Joined 2010-12-02 01:43
15-year member
UID 178698
Gender Male
Status Offline
Dear friends:

Ask a simple question, how to set the content in the file as a variable?

For example, the content of question1.txt is: abc
How can I set abc as $a

Thanks
Floor 2 Posted 2010-12-29 08:59 ·  中国 辽宁 葫芦岛 联通
中级用户
★★
Credits 247
Posts 147
Joined 2009-04-09 20:52
17-year member
UID 142531
Gender Male
Status Offline
Use the external command `nset`
`nset /l1 A=$1 <1.txt`

Indicates that the first word of the first line in 1.txt is assigned to variable A
Floor 3 Posted 2010-12-31 16:46 ·  中国 上海 联通
新手上路
Credits 13
Posts 11
Joined 2010-08-24 11:36
15-year member
UID 172893
Gender Male
From 上海
Status Offline
$a???dos or shell?
If it's DOS, you use a for loop, and in shell, directly use `cat 1.txt`, with backticks around cat
Forum Jump: