I read here: Bash For Loop Examples
that I should not use seq , instead use {1..10}
I am not getting this to work
old code
new code not working
This give error like this error token is "{1..8}"
{1..8} seems to be the correct replacement for $t
also tested this for c in {1..${t}} , not working
This works fine for c in {1..8} , but I need the variable option.
that I should not use seq , instead use {1..10}
I am not getting this to work
old code
Code:
#!/bin/bash
t=$(cat /var/bin/servers | wc -l)
for c in $(seq 1 $t)
do
SERVER[$c]=$(awk 'NR==C { print $2 }' C="$c" /var/bin/servers)
done
Code:
#!/bin/bash
t=$(cat /var/bin/servers | wc -l)
for c in {1..$t}
do
SERVER[$c]=$(awk 'NR==C { print $2 }' C="$c" /var/bin/servers)
done
{1..8} seems to be the correct replacement for $t
also tested this for c in {1..${t}} , not working
This works fine for c in {1..8} , but I need the variable option.