0

I am new at this and I'll simplify my problem. I doing the following script:

echo "Insert number of elements:" 
read elements

echo "Insert md number:" 
read sim

echo "uni_$elements_md$sim.tpr" >> doc.bash

But when I run the doc.bash file it only shows inside:

uni_4.tpr

Please help me, how must I do my echo so that if I put elements as 14 and sim as 4 (just to put an example), it displays:

uni_14_md4.tpr

Thanks.

PesaThe
  • 7,259
  • 1
  • 19
  • 43
ananvodo
  • 371
  • 5
  • 13
  • `${elements}_md`. – PesaThe Feb 23 '18 at 01:55
  • 1
    Because `_` is a valid character in a variable name, so bash thinks you want the `elements_md` variable. Use braces to surround the variable name: `echo "uni_${elements}_md$sim.tpr"`. You don't need braces around `sim` because dot is not a valid varname char, although for symmetry it might be more readable to add braces there too. – glenn jackman Feb 23 '18 at 01:56
  • Thanks so much for your quick responsa. It worked perfect. – ananvodo Feb 23 '18 at 02:04

0 Answers0