A
A
Antony2020-08-04 16:02:46
linux
Antony, 2020-08-04 16:02:46

How to sum a column via command in bash?

Hello. Linux and terminal question. I have sample.txt file. It has only one column of numbers. How can I sum up all the numbers in the sample.txt file using a bash command and get the result as a sum output in bash?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-08-04
@anton-gm

awk '{sum += $1} END {print sum}' sample.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question