Joke Collection Website - Blessing messages - How to use the CMD command to rewrite the third line of a text file? For example, enter nihao into the third line of the text.
How to use the CMD command to rewrite the third line of a text file? For example, enter nihao into the third line of the text.
You can only use batch processing to write this, and the number of lines in the original file must not be too many, otherwise the running speed will be very slow
Copy the following command to text file and save it as a file with the extension bat, for example 1.bat
In the following command, 111.txt is the text file you need to replace, 222.txt is the temporary file, pay attention to the space after echo Not too much
input replace row: Enter the line number you want to rewrite
input replace text: Enter the content you want to rewrite
type 111.txt show rewriting text file after
@echo off
setlocal EnableDelayedExpansion
set /p row=input replace row:
set /p strtext =input replace text:
set i=0
for /f "delims=" %%a in (111.txt) do (
set / a i+=1
if !i! == %row% (
echo %strtext% >>222.txt
) else (
echo %%a >>222.txt
)
)
del 111.txt
ren 222. txt 111.txt
type 111.txt
echo on
- Related articles
- Sentences describing the passage of time
- What birthday wishes can be given to the elderly?
- How to reissue the car green paper if it is lost?
- I left my cell phone in the taxi. Is there a lost and found column in Tianjin Traffic Radio? How should I contact?
- How to delete the rental information in 58 cities?
- Wish leaders a happy Mid-Autumn Festival and National Day
- How does Unicom unsubscribe from SMS package?
- How much information does Huaxia transfer have?
- What's wrong with Huawei's mobile phone playing sound for no reason?
- How to recover when the background of SMS turns black?