0

I want the following command to execute 100 times in for loop

cleos push action bescouted registeracc '[$RANDOM]' -p bescouted
cleos push action bescouted vote '[0,$i]' -p bescouted

With variables "$RANDOM" and "$i" showing their real values, but now commands in single quotes are counted as strings. How can I make commands in single quotes execute as written with showed variables instead as strings?

My current script:

#!/bin/sh
cleos push action bescouted posting '[0,"a"]' -p bescouted

for i in {1..100}
do
  cleos push action bescouted registeracc '[$RANDOM]' -p bescouted
  cleos push action bescouted vote '[0,$i]' -p bescouted
done

current output:

cleos push action bescouted registeracc [$RANDOM] -p bescouted
cleos push action bescouted vote [0,$i] -p bescouted
JustinZ
  • 169
  • 7
  • What is your expected output? – Sianur Aug 21 '18 at 14:22
  • my expected output is: cleos push action bescouted registeracc '[RANDOM VARIABLE]' -p bescouted cleos push action bescouted vote '[0,loop number]' -p bescouted – JustinZ Aug 21 '18 at 14:23
  • 2
    Possible duplicate of [Difference between single and double quotes in Bash](https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash) – John Kugelman Aug 21 '18 at 14:23

1 Answers1

1

Use double quotes.

cleos push action bescouted registeracc "[$RANDOM]" -p bescouted
cleos push action bescouted vote "[0,$i]" -p bescouted
John Kugelman
  • 349,597
  • 67
  • 533
  • 578