Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the awk command to connect a string in linux

Shulou Source: shulou.com Published: 2022-06-01 18:02:58 09月16日 Update

This article shows you how to use the awk command to connect strings in linux. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Converting awk strings to numbers

[chengmo@centos5 ~] $awk 'BEGIN {a = "100"; b =" 10test10 "; print (a+b+0);}'

one hundred and ten

You just need to operate the variables through a "+" connection. Automatically forces strings to be converted to integers. When a non-numeric character becomes 0, the first non-numeric character is found and automatically ignored later.

II. Awk numbers are converted into strings

[chengmo@centos5 ~] $awk 'BEGIN {axiom 100 per Bourne C = (a "" b); print c}'

100100

You just need to connect the variable to the "" symbol to operate.

3. Awk string concatenation operation

[chengmo@centos5 ~] $awk 'BEGIN {a = "a"; b = "b"; c = (a "" b); print c}'

Ab

[chengmo@centos5 ~] $awk 'BEGIN {a = "a"; b = "b"; c = (aqb); print c}'

0

String concatenation operations pass through the "two" and "+" operators. The mode forces the values on the left and right sides to be numeric. And then do it.

The above is how to use the awk command to connect strings in linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Characters strings numbers commands content variables skills knowledge coercion operations conciseness brevity that is operators articles more patterns symbols articles types Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Xiaomi Linux NVidia vpn