简体   繁体   English

CMD/BATCH BAT SCRIPT 如何在没有空格的情况下向文件添加数字

[英]CMD/BATCH BAT SCRIPT How to add digit to file without space

i want to make a start.config file by using bat script.我想使用 bat 脚本制作一个 start.config 文件。 I want to add to my config file that parameter:我想在我的配置文件中添加该参数:

StartAgents=9

WITHOUT space at the end of line.行尾没有空格。

Unfortunately command:不幸的命令:

echo StartAgents=9>>C:\start.config

not working, I think that there is "collision" with two characters: "9>"不工作,我认为有两个字符“冲突”:“9>”

Command:命令:

echo StartAgents=9 >>C:\start.config

is working, but this is adding space at the end of line in my config file - i dont want that.正在工作,但这会在我的配置文件的行尾添加空格 - 我不希望这样。

Any ideas how to do that?任何想法如何做到这一点?

I want to add line StartAgents=9 without space af the end of line.我想在行尾添加没有空格的 StartAgents=9 行。 want:想:

StartAgents=9

dont want:不想:

StartAgents=9 

You have to escape the number, so that it isn't interpreted by CMD.EXE as a file descriptor number.您必须对数字进行转义,这样它就不会被 CMD.EXE 解释为文件描述符编号。

Then you can add the >> redirection directly after the number to not insert a trailing space.然后您可以直接在数字后面添加>>重定向,以不插入尾随空格。

Example:例子:

echo StartAgent=^9>>test.txt

Related Information:相关信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM