UNIX GURU UNIVERSE
UNIX HOT TIP
Unix Tip 3153 - September 24, 2009
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
GENERATE RANGES OF NUMBERS
Sometimes it is necessary to generate a range of numbers for further use within a command pipe or shell script. This can be done with some simple sh-code:
------------------------ CUT HERE ------------------
#! /bin/sh
# range - Generate of numbers.
lo=$1
hi=$2
while [ $lo -le $hi ]
do
echo -n $lo " "
lo=`expr $lo + 1`
done
------------------------ CUT HERE ------------------
It can now be used a way like:
for i in `range 69 4711`; do <some code>; done
This tip generously supported by: ulli@ucrc.org
--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today
==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.
Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================
Tidak ada komentar:
Posting Komentar