Do Batch files support multiline variables

前端 未结 9 2023
南旧
南旧 2020-12-25 12:54

If so How?

Yes, batch files are lame, but I cannot use powershell, and I don\'t feel like writing a real app to do this simple task....

edit

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 13:09

    I think I figured it out. I had to add ^ to the %NL% var when putting it in the string, otherwise it hides the text after the first %NL% because its executing when being set, instead of when its being echoed later

    set NL=^& echo
    
    set str=text on line 1 ^%NL% text on line 2
    
    echo %str%
    text on line 1
    text on line 2
    

提交回复
热议问题