How do I get average value showed in the terminal to a separate.dat file using a script?

Hi All,

I am analyzing the radius of gyration (Rg) of polymer chains in my simulations using gmx polystat. There are 60 polymers in my system and I automated calculating Rg. However, I want to get the average values displayed in the terminal after each gmx-polystat step into a separate .dat file. Can anyone help me with this?

I used following for the automated process of calculating Rg

#!/bin/bash

echo 0 | gmx polystat -s …/…/run07.tpr -f run07_nopbc.xtc -o 0.xvg -n index.ndx
echo 1 | gmx polystat -s …/…/run07.tpr -f run07_nopbc.xtc -o 1.xvg -n index.ndx
echo 2 | gmx polystat -s …/…/run07.tpr -f run07_nopbc.xtc -o 2.xvg -n index.ndx
echo 3 | gmx polystat -s …/…/run07.tpr -f run07_nopbc.xtc -o 3.xvg -n index.ndx

Thank you.