awk 字符串拼接

输入文件的内容

TMALL_INVENTORY_30_GROUP    my163149.cm6    3506    5683506    mysql-bin.000013 327359057
TMALL_INVENTORY_31_GROUP    my163149.cm6    3606    5683606    mysql-bin.000017 301259529
$1                          $2              $3      $4         $5               $6

目标

TMALL_INVENTORY_30_GROUP       000013.327359057#5683506.0

awk

 awk  '{position=$5":"$6"#"$4; print $1, position}' posi.txt | awk -F '[.]' '{print $1,$2"."0}' | awk '{print $1,$3}'

字符串拼接,使用双引号"",来连接两边的字符串

输出

TMALL_INVENTORY_30_GROUP mysql-bin 000013:327359057#5683506.0
TMALL_INVENTORY_31_GROUP mysql-bin 000017:301259529#5683606.0

如果输入

awk  '{position=$5":"$6"#"$4; print $1, position}' posi.txt | awk -F '[.]' '{print $1,$2"."0}'

则输出

TMALL_INVENTORY_30_GROUP mysql-bin 000013:327359057#5683506.0
TMALL_INVENTORY_31_GROUP mysql-bin 000017:301259529#5683606.0
如果输入

$ awk  '{position=$5":"$6"#"$4; print $1, position}' posi.txt
则输出

TMALL_INVENTORY_30_GROUP mysql-bin.000013:327359057#5683506
TMALL_INVENTORY_31_GROUP mysql-bin.000017:301259529#5683606






你可能感兴趣的:(awk 字符串拼接)