使用<代码>的的一种方式:
内容:
## Set label a
:a
## While not end of file...
$! {
## If pattern space only has one line, read next one.
/
/! N
## If both lines have same characters until first colon, delete
## second one.
/^([^:]*):.*
1/ s/
.*$//
## If last substitution command (delete repeated line) go to
## label a without reading next input line.
ta
## We are here because last substitution command failed. It
## means that first line is different from second one so
## print && delete first one and save second one to compare in
## next loop.
P
D
}
## This point should be only at end of file, and default action is print so
## it will print last line left in pattern space.
执行文字:
sed -f script.sed infile
结果:
HSDA_17_VerifyShippingOrderNoInOrderConfirmationTest): Timed out after 90 seconds
HSDA_1_BuyVoice): Session not available
HSDA_9_CreateAccounAndBuyDeviceInCheckoutTest): Timed out after 90 seconds
HSDA_2_BuyMapswithNewUserAtCheckOutTest): Address already in use: connect
HSDA_69_ChangeBillingAddressInNonUSLocaleForAllFieldsTest): Index: 0, Size: 0