Question: How Do I Sum a Column in Linux?
Contents

How do you sum a column in Linux?

Linux – Sum using awk

Sum a column of file sizes output from an list (ls) command using awk. for all files that start with php. and print the result divided by 1024 to give the megabytes total.

How do you sum a column in Unix?

$ sed ‘s/,/+/g’ file | bc 2.

Simply print the sum of all the fields. Since we have 3 fields, the sum of $1, $2 and $3 gives the sum of all the numbers of the line.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest