How to print index in a 'for-loop' being executed in remote host through SSH?
- by YShin
I want to ssh into a remote host, and then execute a for loop that goes through sequence of numbers to control number of different nodes.
ssh user@host /bin/bash << EOF
for i in {1..10}
do
echo $i
done
EOF
If I do this, the output is just 10 blank lines, instead of printing out numbers from 1 through 10.
If I execute same code on my local machine, I get the desired output which is ten lines each line printing from 1 through 10.
How would one achieve the intended functionality, that is accessing the index in a for loop that is being executed in SSH?