以下は機能するはずです (一部のシステムでは、すべてのコメントを削除する必要があることに注意してください)。
sed '1 { # if this is the first line
h # copy to hold space
d # delete pattern space and return to start
}
/^}},$/ { # if this line matches regex /^}},$/
x # exchange pattern and hold space
b # print pattern space and return to start
}
H # append line to hold space
$ { # if this is the last line
x # exchange pattern and hold space
s/^}},/}}/ # replace "}}," at start of pattern space with "}}"
b # print pattern space and return to start
}
d # delete pattern space and return to start'
またはコンパクトバージョン:
sed '1{h;d};/^}},$/{x;b};H;${x;s/^}},/}}/;b};d'
例:
$ echo 'parallel (
{
ignore(FAILURE) {
build( "Build2Test", BUILDFILE: "", WARFILE: "http://maven.example.com/130602.0.war", STUDY: "UK", BUG: "33323" )
}},
)' | sed '1{h;d};/^}},$/{x;b};H;${x;s/^}},/}}/;b};d'
parallel (
{
ignore(FAILURE) {
build( "Build2Test", BUILDFILE: "", WARFILE: "http://maven.example.com/130602.0.war", STUDY: "UK", BUG: "33323" )
}}
)