awk:awk_math_operations
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
awk:awk_math_operations [2020/07/15 09:30] – external edit 127.0.0.1 | awk:awk_math_operations [2022/06/13 09:45] (current) – [Advanced Example Using a Variable] peter | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Basic Math Operations ===== | ===== Basic Math Operations ===== | ||
- | Assuming a file exists with following contents: | + | Assuming a file, **test2.txt** |
< | < | ||
Line 17: | Line 17: | ||
<code awk> | <code awk> | ||
- | awk ' | + | awk ' |
</ | </ | ||
- | which will display something like: | + | returns: |
< | < | ||
Line 29: | Line 29: | ||
</ | </ | ||
- | | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
+ | ---- | ||
AWK supports the full range of arithmetic operators including: | AWK supports the full range of arithmetic operators including: | ||
Line 52: | Line 55: | ||
===== Using a Variable ===== | ===== Using a Variable ===== | ||
- | |||
- | Issue the following command: | ||
<code awk> | <code awk> | ||
- | awk ' | + | awk ' |
</ | </ | ||
- | which will display something like: | + | returns: |
< | < | ||
Line 68: | Line 69: | ||
</ | </ | ||
- | This assigns a variable named x. | + | <WRAP info> |
+ | **NOTE: | ||
It has shown a running total and calculated an overall total of 47 items. | It has shown a running total and calculated an overall total of 47 items. | ||
+ | |||
+ | </ | ||
---- | ---- | ||
===== Advanced Example Using a Variable ===== | ===== Advanced Example Using a Variable ===== | ||
- | |||
- | Issue the following command: | ||
<code awk> | <code awk> | ||
- | awk ' | + | awk ' |
</ | </ | ||
- | which will display something like: | + | returns: |
< | < | ||
Line 91: | Line 93: | ||
</ | </ | ||
- | This procedure gives a listing of each record while assigning a total value and keeping a running balance. | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
---- | ---- | ||
awk/awk_math_operations.1594805433.txt.gz · Last modified: 2020/07/15 09:30 by 127.0.0.1