1.

Solve : Prevent exclamation marks from going away?

Answer» <html><body><p>What I am trying to do is use a FOR loop to send the contents of one batch file (<a href="https://interviewquestions.tuteehub.com/tag/starting-1224778" style="font-weight:bold;" target="_blank" title="Click to know more about STARTING">STARTING</a> at the <a href="https://interviewquestions.tuteehub.com/tag/37-247766" style="font-weight:bold;" target="_blank" title="Click to know more about 37">37</a> line) into another. To do this, I use this code:<br/><br/>for /f "skip=36 delims=" %%Z in (batchfile.bat) do echo %%Z &gt;&gt; newbatchfile.bat<br/><br/>However, it removes exclamation marks (which as you may know, can be critically important in batch files). Can someone help me prevent this from removing the exclamation marks?<br/><br/>EDIT: I tried <a href="https://interviewquestions.tuteehub.com/tag/disabling-2058727" style="font-weight:bold;" target="_blank" title="Click to know more about DISABLING">DISABLING</a> delayed expansion and it worked! Thanks anyway!you can use more <br/> Code: <a>[Select]</a>more +36 file &gt;newfile<br/> Quote from: ghostdog74 on July 30, 2010, 10:07:10 PM</p><blockquote>you can use more <br/> Code: <a>[Select]</a>more +36 file &gt;newfile<br/></blockquote> <br/>I noticed that the help for more says <br/><br/> Code: <a>[Select]</a>   +n      Start displaying the first file at line n<br/>in fact more +n skips n lines, and starts displaying the file at line n+1.<br/><br/> Code: <a>[Select]</a>del testfile.txt &amp; for /L %%N in (1,1,<a href="https://interviewquestions.tuteehub.com/tag/40-241999" style="font-weight:bold;" target="_blank" title="Click to know more about 40">40</a>) do echo This is line %%N&gt;&gt;testfile.txt<br/>echo (1) FOR /f "skip=36"<br/>for /f "skip=36 delims=" %%Z in (testfile.txt) do echo %%Z<br/>echo (2) more +36<br/>more +36 testfile.txt<br/><br/> Code: <a>[Select]</a>(1) FOR /f "skip=36"<br/>This is line 37<br/>This is line 38<br/>This is line 39<br/>This is line 40<br/>(2) more +36<br/>This is line 37<br/>This is line 38<br/>This is line 39<br/>This is line 40<br/><br/><br/><br/><br/><br/></body></html>


Discussion

No Comment Found