This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to save BamUtil stats result as text file

Dear all,

I am in trouble to export BamUtil stats result as text file. Could anyone suggest me to solve this problem?

I have tried following

Path/to/bamutil stats --basic --in my.bam > stats.txt
Path/to/bamutil stats --basic --in my.bam | echo > stats.txt

Both couldn't write statistics in text file.

Thank you for your answer,

bamutil

Both couldn't write statistics in text file.

What happens then? Please be as informative as possible since we cannot see what happens on your screen.

Even I have experienced the same problem but then you can always use 'nohup' to get output appended in 'nohup.out'.

i.e you can use below command:

nohup Path/to/bamutil stats --basic --in my.bam

And you can find the stats written in nohup.out file

try @ ttsutsui1028 :

$ bamutil/bam stats --basic --in my.bam |& tee >stats.txt

or

$ bamutil/bam stats --basic --in my.bam 2>&1| tee >stats.txt

1 answer

bamUtil redirects --stats (also --phred and --qual) to sdterr, not to stdout. So if you want to redirect those stats to a file, you have to redirect stderr with 2>stats.txt:

bam stats --basic --in my.bam 2>stats.txt

Log in to answer this question.