can you, please, help with awk command that will count all numbers that are in a file?
Example:
input -> Hi, this is 25 ...
input -> Lalala 21 or 29 what is ... 79?
.
.
(25+21+29+79)
Output: sum of all numbers is: 154
can you, please, help with awk command that will count all numbers that are in a file?
Example:
input -> Hi, this is 25 ...
input -> Lalala 21 or 29 what is ... 79?
.
.
(25+21+29+79)
Output: sum of all numbers is: 154
Try:
awk -F '[a-z=]*' '{x+=$2}END{print x}'
or using GREP
$ grep -o '[[:digit:]]*' file | paste -sd+ - | bc
$ cat data
Hi, this is 25 ...
Lalala 21 or 29 what is ... 79?
$ grep -oP 'bd+b' data | paste -s -d '+' | bc
154
برچسب:
نویسنده: استخدام کار