خرید بک لینک

Vote count: 1

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

asked 10 mins ago

2 Answers

Vote count: 0

Try:

awk -F '[a-z=]*' '{x+=$2}END{print x}'

or using GREP

$ grep -o '[[:digit:]]*' file | paste -sd+ - | bc

answered 8 mins ago

Vote count: 0

$ cat data
Hi, this is 25 ...
Lalala 21 or 29 what is ... 79?
$ grep -oP 'bd+b' data | paste -s -d '+' | bc
154

answered 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 28 ارديبهشت 1395 ساعت: 19:04

صفحه بندی