开发者

Adding text to start of each new line in a .txt file

I would like to add a predefined text to each开发者_运维百科 new line on a text file and create a new text file with the added text. Please help.


In Windows, this will do it:

(for /f "delims=" %L in (oldfile.txt) do @echo predefined text %L)> newfile.txt

Note that in a batch file you'll need to use double % signs:

(for /f "delims=" %%L in (oldfile.txt) do @echo predefined text %%L)> newfile.txt

Note also that if you don't put the ">" right after the %L, you will get a space after every line. If you use ">>" instead of ">" you will keep adding on to newfile.txt instead of creating a new one each time you run it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜