# AWK - Assignment Operators

AWK supports the following assignment operators −

## Simple Assignment

It is represented by =. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { name = "Jerry"; print "My name is", name }'
```

On executing this code, you get the following result −

### Output

```My name is Jerry
```

It is represented by +=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 10; cnt += 10; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 20
```

In the above example, the first statement assigns value 10 to the variable cnt. In the next statement, the shorthand operator increments its value by 10.

## Shorthand Subtraction

It is represented by -=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 100; cnt -= 10; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 90
```

In the above example, the first statement assigns value 100 to the variable cnt. In the next statement, the shorthand operator decrements its value by 10.

## Shorthand Multiplication

It is represented by *=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 10; cnt *= 10; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 100
```

In the above example, the first statement assigns value 10 to the variable cnt. In the next statement, the shorthand operator multiplies its value by 10.

## Shorthand Division

It is represented by /=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 100; cnt /= 5; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 20
```

In the above example, the first statement assigns value 100 to the variable cnt. In the next statement, the shorthand operator divides it by 5.

## Shorthand Modulo

It is represented by %=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 100; cnt %= 8; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 4
```

## Shorthand Exponential

It is represented by ^=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 2; cnt ^= 4; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 16
```

The above example raises the value of cnt by 4.

## Shorthand Exponential

It is represented by **=. The following example demonstrates this −

### Example

```[jerry]\$ awk 'BEGIN { cnt = 2; cnt **= 4; print "Counter =", cnt }'
```

On executing this code, you get the following result −

### Output

```Counter = 16
```

This example also raises the value of cnt by 4.

awk_operators.htm
{"ft_lang_label":"__label__en","ft_lang_prob":0.84132075,"math_prob":0.91693616,"size":2383,"snap":"2019-43-2019-47","text_gpt3_token_len":592,"char_repetition_ratio":0.15889029,"word_repetition_ratio":0.63386726,"special_character_ratio":0.29332775,"punctuation_ratio":0.13073395,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9990509,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-17T02:46:28Z\",\"WARC-Record-ID\":\"<urn:uuid:da9338c9-c303-4870-b443-b53971dd9ec2>\",\"Content-Length\":\"21965\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4a689efb-b340-43f3-b1d5-70f30750018c>\",\"WARC-Concurrent-To\":\"<urn:uuid:5d9dde87-1b6f-4c3d-b89d-114909ba0128>\",\"WARC-IP-Address\":\"72.21.91.42\",\"WARC-Target-URI\":\"https://www.tutorialspoint.com/awk/awk_assignment_operators.htm\",\"WARC-Payload-Digest\":\"sha1:JKKBNBH7BOAFRS45HX4SP6LEXLNRW4FG\",\"WARC-Block-Digest\":\"sha1:GAAAKRAHBLSISUO72CXM74U46GHLQTJZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668782.15_warc_CC-MAIN-20191117014405-20191117042405-00158.warc.gz\"}"}