在不修改段落的情况下将段落的内容回复到文件中?

如何在段落中对段落进行回应,而不对段落进行任何操作。 我的意思是换行,空格,特殊字符等,所有的缩进应该是相同的。

我的.bat文件(包含.ppk文件的内容)

echo (PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20130127 Public-Lines: 6 AAAAB3NzaC1yc2EAAAABJQAAAQBVYEVYbGluh1Ne6psUMsK4TRiqwN8GG+ImbsfC qIYje3S7n3owtEUSDMEc5VvTZTEXk/CKHK6tXhGSNrExXKDhKE2HejY7TFtbc3vU KM4OogxYeZs/0yBX/kVEu5+kIeZ0ZEsq/ve9/hnEVLZ3DFotUoDzzwdd4jAHUZv2 08xk5tTxodh+iO26RVPSaklZrFjbZkqCwPOnVZhK6JqE/7kZyIM+p5W8CH8XPG3r fgU/R4BpwMNz+pYo2iiV3eZApI25lY+IcjclA5Amx1JdCM1zIvA6C8ABUbTMXsyG RHkzdEYjw5+pBF8qLU8s8+M9sw0l5z58dP9t+vuYWz+JrsmL Private-Lines: 14 AAABAECb4XNY9dcaTO3h+NED0aA6V9sqLDv5bN7QX9GUSdWpiMVWF0dzqeQlU96E DiNvLBHXvPLlRer7FDdL+7am9kmGSIIy+JuTusG/LUaba4Cx+4E5bpEqJlBtZNoR ceP9+oGYAYhSPvCkneCuz0VVdKytI1C4WJoS8+nc5LrJyxvsFGgVEIo5nadkABRV eOLwotq2Mj/lLXHMbE5lB+9m9VNsWrBErNVCwNQdhQOyG1E39YcwBV+hB+Pyu41z 6EHxIRXQvbYNE2HjLvowrnX/9fFfx1kf51+WE+VbFQxrrZqE1p3y2S2kJkAopRio KZBlNwrR6mwSLtRn4a6ZecKwVE0AAACBAJVV6O5leR0gl27DVqnXu6mhf6Xb8Ije 2JfvLCa73bgpFSYQ2EpxKTiSpZpM3kPpnC7Y0SvigstGHwze/OuCXYnzT/KDkBrs NDPiuTSmzW3JxtGv1axpfRRt/PaRIHq6pCtyGxIc5A0RrTuSrPzZkHxFggkAYSMK 9YOi1sZhcVtlAAAAgQCSW1Pvq4zSjsUuGMc/w8T8mOOZG4Yllq7e9CSpTMeqeVHl Vytm5+ujIyas/k/UGA8WQt3ZnD5uLF7tBRoaHf88oE00nXVnLlDeME3Jdbts84tE 1HB9RzwGE+BVknEiNcUjqhVcRqv6+pOClR+K5VOstqs/tmmMOA57c1481K/aLwAA AIAQn9Fhg4Ih71uvber4RELcZCQrvRFsuASYHrgYBkzw17PTPQ9APv0B1nIPZ/u6 +jhou7qzR78yrYw0Po4ZJmmDt0CP/cZPWL4jQ6sM6on98D6TdKk7rE1c0WPn1Bta ZtaxQqOku7eAfw745L9EjokekZjohjTFI9rSFdsCfa6dXw== Private-MAC: 2e75877ab827b492b2a0a16c5019cd45f96e4990) > myfile.txt 

上面的行不起作用后,我把它保存为.bat并执行

我想把这个段落放在一个具有唯一名称的文件中,这样它就不会覆盖任何现有的文件。 我是否需要在每一行回显并不断追加。

Solutions Collecting From Web of "在不修改段落的情况下将段落的内容回复到文件中?"

在最后的EXIT / B之后放一个独特的文本标记,然后是段落。 在FINDSTR中使用FOR / F来定位唯一的标记,然后使用FOR / F循环来处理标记之后的所有行。

有许多变化,每个有不同的限制。

这是最简单的形式,但它也是最有限的。 文中描述了这些限制。

 @echo off setlocal disableDelayedExpansion set "skip=" for /f "delims=:" %%N in ( 'findstr /x /n ":::BeginText" "%~f0"' ) do if not defined skip set skip=%%N >test.txt ( for /f "usebackq skip=%skip% delims=" %%A in ("%~f0") do echo(%%A ) type test.txt exit /b :::BeginText This text will be exactly preserved with the following limitations: 1) Each line will be terminated by CR LF even if original has only LF. 2) Lines are limited in length to approximately 8191 bytes. 3) Empty lines will be stripped. ; 4) Lines beginning with ; will be stripped. 5) The text will be truncated at the first occurance of hex code 0x1A (Ctrl-Z). Special characters like ^ & < > | etc. do not cause a problem 

一些奇怪的FOR / F选项语法删除了以下行的限制;

 @echo off setlocal disableDelayedExpansion set "skip=" for /f "delims=:" %%N in ( 'findstr /x /n ":::BeginText" "%~f0"' ) do if not defined skip set skip=%%N >test.txt ( for /f ^usebackq^ skip^=%skip%^ delims^=^ eol^= %%A in ("%~f0") do echo(%%A ) type test.txt exit /b :::BeginText This text will be exactly preserved with the following limitations: 1) Each line will be terminated by CR LF even if original has only LF. 2) Lines are limited in length to approximately 8191 bytes. 3) Empty lines will be stripped. 4) The text will be truncated at the first occurance of hex code 0x1A (Ctrl-Z). Special characters like ^ & < > | etc. do not cause a problem ;Lines beginning with ; are preserved 

读取FINDSTR / N输出而不是直接读取文件保留空行。 但引入了一个新的领导限制:

 @echo off setlocal disableDelayedExpansion set "skip=" for /f "delims=:" %%N in ( 'findstr /x /n ":::BeginText" "%~f0"' ) do if not defined skip set skip=%%N >test.txt ( for /f "skip=%skip% tokens=1* delims=:" %%A in ( 'findstr /n "^" "%~f0"' ) do echo(%%B ) type test.txt exit /b :::BeginText This text will be exactly preserved with the following limitations: 1) Each line will be terminated by CR LF even if original has only LF. 2) Lines are limited in length to approximately 8191 bytes. ::: 3) Leading : will be stripped from each line. Special characters like ^ & < > | etc. do not cause a problem Empty lines are preserved! ;Lines beginning with ; are preserved. 

这最后的版本是一样好。 延时扩展必须切换开关来保存! 可能会出现在文本中。

 @echo off setlocal disableDelayedExpansion set "skip=" for /f "delims=:" %%N in ( 'findstr /x /n ":::BeginText" "%~f0"' ) do if not defined skip set skip=%%N >test.txt ( for /f "skip=%skip% tokens=*" %%A in ( 'findstr /n "^" "%~f0"' ) do ( set "line=%%A" setlocal enableDelayedExpansion echo(!line:*:=! endlocal ) ) type test.txt exit /b :::BeginText This text will be exactly preserved with the following limitations: 1) Each line will be terminated by CR LF even if original has only LF. 2) Lines are limited in length to approximately 8191 bytes. Special characters like ^ & < > | etc. do not cause a problem. Empty lines are preserved! ;Lines beginning with ; are preserved. :::Leading : are preserved.