#!/bin/sh
for i in {1..5}
do
echo "Welcome"
done
Would work, displays Welcome 5 times.
#!/bin/sh
howmany=`grep -c $1 /root/file`
for i in {1..$howmany}
do
echo "Welcome"
done
Doesn't work! howmany
would equal 5 as that is what the output of grep -c
would display. $1 is parameter 1 which is specific when running the script.
Any ideas?
x=5; for i in {1..$x}; do echo "Hi"; done
and also doesn't work. It only printsHi
once. – Argybargyexp={0..9}; echo $exp; 0 1 2 3 4 5 6 7 8 9
– Elastomerseq
idea from but that doesn't work with alphabetic characters. I couldn't find a solution to my problem at that answer, unless I'm missing it. – Hofmann{$range}
or at the very least{$rangeFrom..$rangeTo}
but bash doesn't support this. – Hofmannksh
. I know the limitations ofbash
. – Elastomer