ls | map (f: f.size) | red + | map (size: size / 1024)
You can also leave off "map", so:
ls | (f: f.size) | red + | (size: size / 1024)
A pipeline produces a stream, so there's no clean way to get the single int result in a variable, but you can store the stream (containing the int) into a variable:
ls | ... | (size: size / 1024) >$ x
Now x has the stream. To read back the stream and print it: