Is there a way to sum up the size of files listed?

First of all, you should use straight single quotes ('), not the inclined ones (`).

The awk inline script could be as follow:

ls -lrt | awk '{ total += $5 }; END { print total }'

so, no need to initialize total (awk initializes it to zero), and no need to loop, awk already executes the script on every line of input.


@enzotib has already pointed out what your syntax error is - I'm going to go off on a little tangent.

Summing a column of numbers is one of those things that keeps popping up. I've ended up with this shell function:

sumcol() 
{ 
    awk "{sum+=\$$1} END {print sum}"
}

With this, your solution becomes:

ls -lrt | sumcol 5

That will sum the numbers in column 5 and print the value.


Here is another way to do this by using du:

find . -name \*.extract.sys -size +1000000c -print0 | du -c --files0-from=- | awk 'END{print $1}'