#
# Bourne shell functions similar to 'seq' in linux, except without step
# you can use it to do this in a for loop
# for i in `range 1 100`
# do
# do-something
# done
#
range1()
{
start=$1
end=$2
count=$start
rc=""
while [ $count -le $end ]
do
rc="$rc $count"
count=`expr $count + 1`
done
echo $rc
}
range2()
{
perl -e "\$,=\" \"; print $1..$2;"
}
range3()
{
gawk -v s=$1 -v e=$2 'END{for(i=s;i<=e;++i) {printf("%d ",i)}}' /dev/null
}
range4()
{
echo "for {set i $1} {\$i<=$2} {incr i} {puts -nonewline \"\$i \"}" | tclsh
}
range5()
{
yes | pr -f -n | head -`expr $2 + 3` | tail -`expr $2 - $1 + 1` | cut -c1-5
}
0 Comments:
Post a Comment
<< Home