更新时间:2023-12-03 22:39:40
sed
会做到:
sed '/\n/!N;/\n.*\n/!N;/\n.*\n.*PINITIAL BALANCE/{$d;N;N;d};P;D'
它是这样工作的:
为防止在第一个字符串上出现图案,应修改脚本:
To prevent the appearance of pattern on the first string you should modify the script:
sed '1{/PINITIAL BALANCE/{N;N;d}};/\n/!N;/\n.*\n/!N;/\n.*\n.*PINITIAL BALANCE/{$d;N;N;d};P;D'
但是,如果您要删除的另一个字符串PINITIAL BALANCE
失败了.但是,其他解决方案也失败=)
However, it fails in case you have another PINITIAL BALANCE
in string which are going to be deleted. However, other solutions fails too =)