#!/bin/bash################################################# a brilliant replacement for seq that uses bc ################################################### first test the number of argumentsif [ $# -lt 2 ]; then echo "Usage: seq <start> [increment] <stop>" exitfi# next, see if bc is presentif ! [ -e /usr/bin/bc ]; then echo "Cannot execute seq. bc is not found" exitfi# set value at the start-valueVALUE=$1FINAL_VALUE=$2# if the number of arguments is only 2, then increase with 1INCREMENT=1# otherwise use the increment specifiedif ! [ $# -lt 3 ]; then FINAL_VALUE=$3 INCREMENT=$2fi #calculate the number of steps to use NR_STEPS=$(echo "1+($FINAL_VALUE-$VALUE)/$INCREMENT" | bc)#initialize a counterCOUNTER=0#now, finally, calculate all the numbers in the sequencewhile [ $COUNTER -lt $NR_STEPS ]; do echo $VALUE VALUE=$(echo "$VALUE+$INCREMENT" | bc) let COUNTER+=1done
# next, see if bc is presentif ! [ -e /usr/bin/bc ]; then echo "Cannot execute seq. bc is not found" exitfi
# set value at the start-valueVALUE=$1FINAL_VALUE=$2
# if the number of arguments is only 2, then increase with 1INCREMENT=1
# otherwise use the increment specifiedif ! [ $# -lt 3 ]; then FINAL_VALUE=$3 INCREMENT=$2fi #calculate the number of steps to use NR_STEPS=$(echo "1+($FINAL_VALUE-$VALUE)/$INCREMENT" | bc)
#initialize a counterCOUNTER=0
#now, finally, calculate all the numbers in the sequencewhile [ $COUNTER -lt $NR_STEPS ]; do echo $VALUE VALUE=$(echo "$VALUE+$INCREMENT" | bc) let COUNTER+=1done
(Bewerkt door mennodeij om 16:26, 18-04-2006)
seq 2 102345678910
seq 1.1 0.5 8.01.11.62.12.63.13.64.14.65.15.66.16.67.17.6