Reader small image

You're reading from  Learning AWK Programming

Product typeBook
Published inMar 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788391030
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Shiwang Kalkhanda
Shiwang Kalkhanda
author image
Shiwang Kalkhanda

Shiwang Kalkhanda (RHCA, RHCSS, MCSE) is a Linux geek and consultant with expertise in the automation of infrastructure deployment and management. He has more than 10 years' experience in security, system, and network administration, and training on open source tech. For most of his automation work, he uses Shell Scripting, Python, and Go. He holds a master's and a bachelor's degree in computer applications. He enjoys traveling and spending time with his children. He is also the author of a book on text processing utilities in Unix-like environments, Learning Awk Programming.
Read more about Shiwang Kalkhanda

Right arrow

Increment and decrement expressions

AWK also supports the increment ++ and decrement -- operators; they increase or decrease the value of a variable by one. Both operators are similar to the operators in C. These operators can only be used with a single variable and, thus, only before or after the variable. They are the short forms of some common operations of adding and subtracting.

Pre-increment:

It is represented by the plus plus (++) symbol prefixed to the variable. It increments the value of an operand by one. Let's say we have a variable, var; to pre-increment its value, we write ++var. It first increments the value of operand and then returns the incremented value. In the following example, we use two variables, p =5 and q = ++p. Here, first the value is incremented and then it is assigned. So, the pre-increment sets both the operands p and q to 6. It is equivalent...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning AWK Programming
Published in: Mar 2018Publisher: PacktISBN-13: 9781788391030

Author (1)

author image
Shiwang Kalkhanda

Shiwang Kalkhanda (RHCA, RHCSS, MCSE) is a Linux geek and consultant with expertise in the automation of infrastructure deployment and management. He has more than 10 years' experience in security, system, and network administration, and training on open source tech. For most of his automation work, he uses Shell Scripting, Python, and Go. He holds a master's and a bachelor's degree in computer applications. He enjoys traveling and spending time with his children. He is also the author of a book on text processing utilities in Unix-like environments, Learning Awk Programming.
Read more about Shiwang Kalkhanda