Pages

Wednesday, March 13, 2013

bash loop interval

For loop in bash using an interval is fairly simple:
    for i in {1..3}; do echo "r${i}r";done
It becomes a bit more complicated if you want to use a parametric value for the end of the interval:
    n=5
    for i in $(seq 1 $n);do echo "r${i}r";done

No comments:

Post a Comment