Get the App
SLTechnology News&Howtos  ›  Servers  › 

An example introduction of linux awk operator

Shulou Source: shulou.com Published: 2022-06-01 12:19:10 10月19日 Update

This article introduces the relevant knowledge of "linux awk operator example introduction". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. introduction of operators

Operator describes the assignment operator = + =-= * = / =% = ^ = * * = assignment statement logical operator | | logical or & & logical and regular operator ~! Match regular expression and mismatch regular expression relational operator

< >

=! = Relational operator +-add, subtract * / & multiply, divide and find remainder + -! Unary addition, subtraction and logic is not ^ * exponentiation + +-- increase or decrease, as a prefix or suffix other operator $field references the space string hyphen?: C conditional expression in array whether there is a key value

Description: awk operator is basically the same as c language. The expressions and functions are basically the same.

II. Introduction of examples

Awk assignment operator

The code is as follows:

Equivalent to: aura 5; others of the same kind

Awk logical operator

The code is as follows:

[chengmo@localhost ~] $awk 'BEGIN {a print 1 & & b5 | | b = 9) {print "print";}}'

[chengmo@localhost ~] $awk 'BEGIN {axi11transferif (a > = 9) {print "ok";}}'

Ok

Awk arithmetic operator

The code is as follows:

Note that all operands are used as arithmetic operators, operands are automatically converted to numeric values, and all non-numeric values become 0.

[chengmo@localhost ~] $awk 'BEGIN {a = "b"; print axioms

0 2

Other operators

The code is as follows:

Operator

[chengmo@localhost ~] $awk 'BEGIN {a = "b"; print asides = "b"? "ok": "err";}'

Ok

In operator

[chengmo@localhost ~] $awk 'BEGIN {a = "b"; arr [0] = "b"; arr [1] = "c"; print (an in arr);}'

0

[chengmo@localhost ~] $awk 'BEGIN {a = "b"; arr [0] = "b"; arr ["b"] = "c"; print (an in arr);}'

one

The in operator to determine whether the key exists in the array.

This is the end of the introduction to the example of linux awk operator. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Operators operations codes characters strings logic numeric values regularities expressions instances arithmetic same content operands arrays more knowledge utility learning and then Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Xiaomi MariaDB Docker Huawei