geplaatst door: mennodeij
Het geweldige commando seq - dat onder Linux gewoon standaard aanwezig is - is helaas niet beschikbaar in de Terminal (voor zover ik heb kunnen ontdekken). Daarom dit vervangende scriptje, dat gebruik maakt van bc (dat gelukkig wel aanwezig is in Mac OS X):


#!/bin/bash
################################################
# a brilliant replacement for seq that uses bc #
################################################
#
# first test the number of arguments
if [ $# -lt 2 ]; then
       echo "Usage: seq <start> [increment] <stop>"
       exit
fi

# next, see if bc is present
if ! [ -e /usr/bin/bc ]; then
       echo "Cannot execute seq. bc is not found"
       exit
fi

# set value at the start-value
VALUE=$1
FINAL_VALUE=$2

# if the number of arguments is only 2, then increase with 1
INCREMENT=1

# otherwise use the increment specified
if ! [ $# -lt 3 ]; then
       FINAL_VALUE=$3
       INCREMENT=$2
fi

#calculate the number of steps to use
NR_STEPS=$(echo "1+($FINAL_VALUE-$VALUE)/$INCREMENT" | bc)

#initialize a counter
COUNTER=0

#now, finally, calculate all the numbers in the sequence
while [ $COUNTER -lt $NR_STEPS ]; do
       echo $VALUE
       VALUE=$(echo "$VALUE+$INCREMENT" | bc)
       let COUNTER+=1
done

(Bewerkt door mennodeij om 16:26, 18-04-2006)

Vu-ja-dé: the odd feeling nothing has ever happened before...
vervanging voor het (missende) commando seq in terminal
18 april 2006 - 16:43    reactie #1
geplaatst door: BOlle
man jot?
Apple Certified System Administrator
vervanging voor het (missende) commando seq in terminal
18 april 2006 - 16:50    reactie #2
geplaatst door: mennodeij
Hmm... Dat kan ook, maar als je de syntax van seq bent gewend, dan is jot wel wennen.
Vu-ja-dé: the odd feeling nothing has ever happened before...
vervanging voor het (missende) commando seq in terminal
18 april 2006 - 18:53    reactie #3
geplaatst door: mwesterl
Nu heb ik geen idee wat het sec commando doet, maar kan je het niet vinden via darwinports.org?
iPhone 6 Plus - iPad 1 & Air - Macbook Pro 13" - iMac G4 (bolletje) 15/17" - Powermac G5 - Apple TV 2 & 4
vervanging voor het (missende) commando seq in terminal
18 april 2006 - 21:41    reactie #4
geplaatst door: mennodeij
Ik heb wel gezocht via Fink, met Darwinports ben ik niet bekend. seq doet overigens een sequentie van getallen op het scherm schrijven:

seq 2 10
2
3
4
5
6
7
8
9
10

seq 1.1 0.5 8.0
1.1
1.6
2.1
2.6
3.1
3.6
4.1
4.6
5.1
5.6
6.1
6.6
7.1
7.6

Vu-ja-dé: the odd feeling nothing has ever happened before...