Create a file with echo in DOS without inserting a carriage return

时光毁灭记忆、已成空白 提交于 2020-01-14 13:47:48

问题


I want to create a new file on my CIFS mount in DOS. If I do..

echo hello > foo.txt

There is going to be a CR at the end of hello. How can I create a file at the DOS cmd using echo and not have a CR automatically appended. It is causing problems with samba and my CIFS mount.


回答1:


echo.|set /P ="hello" > foo.txt



回答2:


Try this: set /p "noEOL=hello" <nul >foo.txt

set /p outputs what comes after the equal sign to prompt the user for input (see help set). If you redirect the user input from nul it is happy to continue, redirecting its output to your foo.txt. The name of the variable to assign to is arbitrary (here noEOL).



来源:https://stackoverflow.com/questions/5623599/create-a-file-with-echo-in-dos-without-inserting-a-carriage-return

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!