更新时间:2023-12-03 21:34:58
这对我来说适用于你的输入文件:
This works for me with your input file:
sed -n '1h; 1!H; ${ g; s/Mary\n\n/\n/g p }'
说明:
Mary\n\n # Mary with two consecutive newlines, the first one is automatically added by
# the 'H' command, and the next one means the empty line, asumming it has no
# spaces.
\n # Substitute it with a blank line.