UNIX / Linux: awk Add Two Numbers

www.l‮a‬utturi.com
UNIX / Linux: awk Add Two Numbers

To add two numbers in the UNIX/Linux awk command, you can use the + operator. For example, to add the numbers 5 and 10, you would use the following command:

awk 'BEGIN {print 5 + 10}'

This will print the result of the addition, 15, to the terminal.

Alternatively, you can use the awk command to read the numbers from a file or from standard input. For example, to add the numbers in the file numbers.txt, you could use the following command:

awk '{print $1 + $2}' numbers.txt

This will read the first two numbers in each line of the numbers.txt file, and print the sum of those numbers to the terminal.

Created Time:2017-10-16 14:38:54  Author:lautturi