For the specific issue you are talking about, use John's suggestion above.
I would say that if you ever need something like this that cannot be solved with the bash template expansion syntax, you don’t need to create temporary files to convert the contents using sed or similar commands. Firstly, you can pass the variable directly to the program as STDIN. Secondly, you can get the output of a command (or its STDOUT, STDERR, or both) directly into a shell variable.
So in your example you would have:
for P in 0.10 0.20 [...] 0.90 1.00 ; do for Q in 0.10 0.20 [...] 0.90 1.00 ; do P_REP=$( sed 's/\./_/g' <<< "$P" ) Q_REP=$( sed 's/\./_/g' <<< "$Q" ) done done
Note also that the syntax of the array (that is, { '0.10', '0.20', ...} ) is mostly specific to bash and very few Bash-following. When this is easy to do, you may prefer a more classical approach to shell loops, since I was above that. Your code will then be executed safely in all posix compatible shells.
source share