입력하다:
@@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