sed 的不会写 写了个awk的 你看行不行
test@sever:/tmp> cat 1
HKFJ 210700Z 15002MPS 5000 BR NSC 10/09 Q1025 NOSIG
FKHJ 210700Z 07006MPS 9999 -RA SCT040 10/M00 Q1020 NOSIG
test@sever:/tmp> cat 2
HKFJ::HKFJ 100030Z 09010MPS CAVOK 13/05 Q1027 NOSIG::HKFJ 092240Z 100009 33006G11MPS CAVOK BECMG 0506 33004MPS::292,009,07.5/312,021,03.3/324,028,-00.3/314,033,-04.6/295,035,-18.8/286,042,-31.3/286,052,-43.3/284,066,-50.9/279,081,-55.2/275,088,-55.7/272,076,-63.2<br>FKHJ::FKHJ 100000Z 16001MPS CAVOK 02/M01 Q1030 NOSIG::FKHJ 091935Z 100024 33004MPS CAVOK::351,007,07.2/347,007,01.7/335,016,01.1/326,026,-05.6/312,040,-18.5/308,044,-31.2/295,043,-44.5/287,051,-52.1/283,068,-57.5/278,075,-57.2/276,068,-63.0<br>
test@sever:/tmp> awk 'NR==FNR{a[$1,$NF]=$0;next}{for(i in a){split(i,b,SUBSEP);m=b[1]"[^:]*"b[2];n=a[i];gsub(m,n)}}1' 1 2
HKFJ::HKFJ 210700Z 15002MPS 5000 BR NSC 10/09 Q1025 NOSIG::HKFJ 092240Z 100009 33006G11MPS CAVOK BECMG 0506 33004MPS::292,009,07.5/312,021,03.3/324,028,-00.3/314,033,-04.6/295,035,-18.8/286,042,-31.3/286,052,-43.3/284,066,-50.9/279,081,-55.2/275,088,-55.7/272,076,-63.2<br>FKHJ::FKHJ 210700Z 07006MPS 9999 -RA SCT040 10/M00 Q1020 NOSIG::FKHJ 091935Z 100024 33004MPS CAVOK::351,007,07.2/347,007,01.7/335,016,01.1/326,026,-05.6/312,040,-18.5/308,044,-31.2/295,043,-44.5/287,051,-52.1/283,068,-57.5/278,075,-57.2/276,068,-63.0<br>
test@sever:/tmp> |