Possible duplicate
Hello,
I'm struggling with output redirection within a bash for loop. I have several similar bash scripts, each scripts being launched on a different input file. The scripts called a tool with a few arguments.
The bash scripts are like this :
my_tool --input input_file --arg1 arg1_name --arg2 arg2_name > output_dir/result_X.dat
X
being a string which is unique for each script.
I run all of them in a for loop :
for script in scripts_dir/*.sh
do
bash $script
done
However, the stdout of each run still display on the terminal. The specified output files are created, but empty. How I can solve that ? I found other questions on stackoverflow where the answer is a redirection of the full loop in one big output file, but I'd like to avoid that.
If I replace > output_dir/result_X.dat
by > /dev/null
: the standard outputs display on the terminal
If I replace > output_dir/result_X.dat
by ` 2> /dev/null : nothing is displayed.
Thanks in advance.