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

偶尔善良 提交于 2019-12-11 01:44:49

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/2253134/adding-text-to-start-of-each-new-line-in-a-txt-file

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