问题
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