我有这个文件:
# cat pt_Sed.txt
ULNET-PA,broker_etrade,broker_etrade_uk^M,BR DELIVERTOCOMPID
ULNET-PA,broker_etrade,broker_etrade_uk^M,CO TARGETSUBID
我想排列线条,使它们看起来像这样:
ULNET-PA,broker_etrade,broker_etrade_uk^M,DELIVERTOCOMPID=BR
ULNET-PA,broker_etrade,broker_etrade_uk^M,TARGETSUBID=CO
我尝试了以下方法,但似乎没有按预期工作:
# x=`awk '{ print $NF }' pt_Sed2.txt`
# echo $x
# DELIVERTOCOMPID
# sed -re "s/\^M,*/&$x=/g" -e 's/ .*//' < pt_Sed.txt
# ULNET-PA,broker_etrade,broker_etrade_uk^M,DELIVERTOCOMPID=BR
# ULNET-PA,broker_etrade,broker_etrade_uk^M,DELIVERTOCOMPID=CO
你能提出一个解决方案吗?我将不胜感激!
谢谢,安德烈