Shell awk command string concatenation

Source: Internet
Author: User

The content of this section:
The awk command implements the concatenation of strings

Enter the contents of the file:

Tmall_inventory_30_group    my163149.cm6    3506    5683506    mysql-bin.  000013327359057  tmall_inventory_31_group    my163149.cm6    3606    5683606    mysql-bin.  000017301259529  $1                          $2              $3      $ 4         $5               $6

Goal:
Tmall_inventory_30_group 000013.327359057#5683506.0
Awk

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

string concatenation, using double quotes "", to concatenate strings on both sides
Output
Tmall_inventory_30_group Mysql-bin 000013:327359057#5683506.0
Tmall_inventory_31_group Mysql-bin 000017:301259529#5683606.0

If you enter:

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

The output:
Tmall_inventory_30_group Mysql-bin 000013:327359057#5683506.0
Tmall_inventory_31_group Mysql-bin 000017:301259529#5683606.0
If you enter:

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

The output:
Tmall_inventory_30_group mysql-bin.000013:327359057#5683506
Tmall_inventory_31_group mysql-bin.000017:301259529#5683606

Here are some examples of how the awk command implements string concatenation, which can be useful for log analysis and routine maintenance, using the awk command in Linux.

Shell awk command string concatenation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.