输入:
@@string1
string2,
word
@@string3
string4,
word
@@string5, word
期望的输出:
@@string1string2,word
@@string3,string4,word
@@string5, word
尝试过
sed -n '/^@@/{:a;N;/^@@/!ba};/^@@/s/\n//g;p'
不工作
答案1
与sed (GNU sed) 4.7
, 尝试
sed -z 's/\n//g; s/@@\|$/\n&/2g' file
@@string1string2,word
@@string3string4,word
@@string5, word