This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to save trimmomatic terminal summary to an output file?

I can't use the trimmomatic -trimlog output because it severely slows down the process and I just want to save the summary statistics. The statistics show up as the stdout on the terminal window but I cannot figure out how to save that to my own output file in my bash script.

#!/bin/bash
for files in .
do
java -jar /path/to/trimmomatic-jar SE -phred33 ${files} ${files%%.fastq}_trimmed.fastq ILLUMINACLIP:/path/to/trimmomatic/adapters.fa:2:30:10 SLIDINGWINDOW:4:20 > log.txt
done

Using > log.txt at the end does not work, neither did: command | tee log.txt nor did command >> script log.txt nor did command 2& > log.txt

Anyone have any ideas?

trimmomatic

2 answers

Thanks for the help everyone but I got it to work simply with:

commands &>> output.file

This allowed me to save the actual output from the terminal instead of using trimlog which TAKES FOREVER. Now this saves just the main statistics all in one file neatly.

&>> appends STDOUT and STDERR to the same file. You might benefit from not mixing stuff up and piping 2>file.err 1>file.out

Agreed. Once you start using pipes (and you will/should for larger NGS data) this &>> will likely eventually corrupt your output files. Go with the suggestion of Wouter using 2>.

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they all work.

Upvote|Bookmark|Accept

I think it's written to stderr, not stdout, so you can redirect those logs to a file as below:

command 2> log.txt

Log in to answer this question.