This is a test version of Biostars. For the public version, visit https://www.biostars.org.
I need to perform a sum with values from several outputs of a program

Hi all,

I need to perform a sum with values from several outputs of a program. The loop is the following and it's perfect:

cat lista | while read l; do vdb-dump $l --info; done

However, I need to select the size values and perform a sum to get the total value of the files. In this case there are only two.

acc    : SRR3900953
path   : https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR3900953/SRR3900953
size   : 339,610,771
type   : Table
platf  : SRA_PLATFORM_ILLUMINA
SEQ    : 4,941,237
SCHEMA : NCBI:SRA:Illumina:tbl:phred:v2#1.0.4
TIME   : 0x000000005787d950 (07/14/2016 13:26)
FMT    : Fastq
FMTVER : 2.6.3
LDR    : fastq-load.2.6.3
LDRVER : 2.6.3
LDRDATE: May 16 2016 (5/16/2016 0:0)
acc    : SRR000001
path   : https://sra-pub-run-odp.s3.amazonaws.com/sra/SRR000001/SRR000001
size   : 312,527,083
type   : Table
platf  : SRA_PLATFORM_454
SEQ    : 470,985
SCHEMA : NCBI:SRA:_454_:tbl:v2#1.0.7
TIME   : 0x0000000055248a41 (04/07/2015 20:54)
FMT    : SFF
FMTVER : 2.4.5
LDR    : sff-load.2.4.5
LDRVER : 2.4.5
LDRDATE: Feb 25 2015 (2/25/2015 0:0)

The result should be total size = 652,137,854

Many thanks,

loop

1 answer

xargs -a lista -L1 grep '^size' | cut -d ':' -f 2 | tr -d "," | paste -s -d '+' |bc

It's fantastic my friend, thank you very much!

Log in to answer this question.