Ubuntu – Print two variables in one line

command linescriptssh

I wanted two print to variables in one line. I am using a shell script #!/bin/sh loop and what I wanted to do is a for repeat which prints out something like:

variable1_case1
variable2_case2

and I have already tried

variable$i_case$i.

Best Answer

for i in 1 2; do
  echo variable${i}_case$i
done

should do what you want. Substitute 1 2 with the numbers or strings you need. Dependent on the values of $i you may need to quote it like so: echo variable"$i"_case"$i".

Related Question