I need to perform a sum with values from several outputs of a program
1
0
Entering edit mode
22 months ago
pavelasquezv ▴ 50

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 • 560 views
ADD COMMENT
2
Entering edit mode
22 months ago
xargs -a lista -L1 grep '^size' | cut -d ':' -f 2 | tr -d "," | paste -s -d '+' |bc
ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2829 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6