11智能在线
新记
bat替换指定行的内容中,指定的字符串
比如说:
11,aa
22,aa
33,bb
44,aa
我只想将第一行的aa替换为“haha”,第二行和第四行的都不替换
或者可以这样解释,文件中,有多个指定的字符串,我只要替换第一个,其他的不替换
举报该文章
相关建议 2016-08-22
@echo off&setlocal enabledelayedexpansion
set "s=aa"
set "d=haha"
(for /f "delims=" %%a in (1.txt) do (
set "str=%%a"
if not defined a (
if not "!str:%s%=!"=="%%a" (
set str=!str:%s%=%d%!
set a=.
)
)
echo,!str!
))>2.txt
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/s8vqsvv784vp8qsv7s.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
bat替换指定行的内容中,指定的字符串
批处理 如何替换含有指定字符串的行中的指定内容
批处理如何实现文本文件中指定行内容的替换?
批处理文本,查找并替换指定字符串所在的行
bat替换指定的内容,比如文件中有一个 a=123,然后要替...
批处理替换txt中2个指定字符(字符串)中间的文本
bat 批处理 把文件名中特定字符替换成另外字符