我需要创建一个脚本,它可以将一行文本写入批处理文件所在目录中的文本文件。
发布于 2015-04-15 03:24:05
只使用一个代码块更容易,那么您只需要一个重定向。
(
echo Line1
echo Line2
...
echo Last Line
) > filename.txt
发布于 2015-07-15 14:06:38
echo "blahblah"> txt.txt
会删除txt并将其放回原处
echo "blahblah">> txt.txt
将在txt中的新行上写入blahblah。
我认为两个都会创建一个新的txt,如果不存在的话(我知道第一个是存在的)
在上面写"txt.txt
“的地方,如果需要的话,可以插入一个文件路径。例如C:\Users\<username>\desktop
,它会把它放在他们的桌面上。
发布于 2013-11-10 03:10:35
@echo off
(echo this is in the first line) > xy.txt
(echo this is in the second line) >> xy.txt
exit
两个>>
意味着第二行将被附加到文件中(即第二行将在xy.txt的最后一行之后开始)。
这是xy.txt
的外观:
this is in the first line
this is in the second line
https://stackoverflow.com/questions/19878136
复制相似问题