Hi,
Oddly, when I run your script I get one column, not one row.
Anyway, I think the following is a simple and flexible way to do this in a short script:
list=""
for filename in ver_a1 ver_a2 ver_a3 ENDLINE ver_b1 ver_b2 ver_b3 ENDLINE ; do
if [ $filename = ENDLINE ] ; then
echo $list >> out.txt
list=""
else
fname=`$FSLDIR/bin/remove_ext ${filename}`
list="${list}`fslstats ${fname} -M` "
fi
done
As then you can use the keyword ENDLINE in the list to indicate the end of the current line whenever you wanted.
Don't forget to put one at the end of the list though, as otherwise the last set gets lost (or you could force it to be output after the loop with one extra echo line).
All the best,
Mark
On 8 Jan 2013, at 09:19, Moran Artzi <[log in to unmask]> wrote:
> Dear experts,
> Is it possible to arrange output data in text file arranged in row and columns,
> i.e.
> I want to get the mean value of several variable (ver_a1, ver_a2, ver_a3, ver_b1, ver_b2, ver_b3), arranged in a test file in this way (Two rows, three columns):
> ver_a1 ver_a2 ver_a3
> ver_b1 ver_b2 ver_b3
>
> Using the default option:
> for filename in ver_a1 ver_a2 ver_a3 ver_b1 ver_b2 ver_b3; do
> fname=`$FSLDIR/bin/remove_ext ${filename}`
> fslstats ${fname} -M >> out.txt
> done
>
> I get all values in one row.
> Is it possible to sort the results as required?
>
> Many thanks
> Moran
|