例如,我有如下数据:
Transmit.123 Invite Members A
Transmit.123 Invite Members GC
Transmit.111 Invite Members F
Transmit.222 Invite Members DE
Transmit.222 Invite Members H
Transmit.333 Invite Members M
Transmit.333 Invite Members KL
输出文件应包含以下数据:
Transmit.123 Invite Members AGC
Transmit.222 Invite Members DEH
Transmit.333 Invite Members MKL
答案1
像这样的东西:
cat file |
perl -ne '/(Transmit.\d+ Invite Members )(.*)/ and $a{$1}.=$2;
END { print map { $_,$a{$_},"\n" } sort keys %a }'