#!/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. – Shahbaz