I'm running a large loop that calls a program that outputs a single value. I would like to redirect that output to a text file appended by a space rather than a new line. Is there any way to do this?
for i in {1..1000000000}; do
mincstats file${i}.mnc -mean -quiet >> output.txt
done
I have tried assigning the output to a variable as below, but I think this may be taking up unnecessary processing time. What would be the most efficient way to do this?
for i in {1..1000000000}; do
var=$(mincstats file${i}.mnc -mean -quiet)
echo -n $var >> output.txt
done
echois a built-in; it's not going to use any significant amount of time over whatmincstatsalready requires.