xjiain 当前离线
上等兵
评分人数
broly (Broly)当前离线
版主
TOP
awk 当前离线
上尉
sed -i "s/222/&\naaa/;s/444/ddd/" a.txt复制代码
FOR 当前离线
中尉
@echo off gawk "{if ($0==\"444\"){print \"ddd\"}else {if($0==\"222\"){print $0,\"\naaa\"}else{print}}}" a.txt pause复制代码
gawk "/222/{$0=$0\"\naaa\"}/444/{$0=\"ddd\"}1" a.txt >b.txt复制代码
gawk "{print /222/?$0\"\naaa\":/444/?\"ddd\":$0}" 1.txt复制代码
sed -e "/222/a\aaa" -e "s/444/ddd/" 1.txt复制代码
Seder 当前离线
一级士官
@echo off set n=5 gawk "{{var=/222/?$0\"\naaaa\":/444/?\"dddd\":$0};if(var!=$0){i++;if(i<=%n%){$0=var}}print}" a.txt pause复制代码
545810831 当前离线
二级士官
@echo off&setlocal enabledelayedexpansion (for /f "delims=" %%i in (1.txt) do ( set str=%%i&set str=!str:444=ddd! echo !str! if "!str!" equ "222" echo aaa ) )>>3.txt pause 复制代码