Given a list of files in files.txt
, I can get a list of their sizes like this:
cat files.txt | xargs ls -l | cut -c 23-30
which pr
If you have R, you can use:
> ... | Rscript -e 'print(sum(scan("stdin")));'
Read 4 items
[1] 2232320
Since I'm comfortable with R, I actually have several aliases for things like this so I can use them in bash
without having to remember this syntax. For instance:
alias Rsum=$'Rscript -e \'print(sum(scan("stdin")));\''
which let's me do
> ... | Rsum
Read 4 items
[1] 2232320
Inspiration: Is there a way to get the min, max, median, and average of a list of numbers in a single command?