How does one mske an array in bourne shell
thanks
Also if one could point me to a good bourne shell site it would be great.
Bibek
How does one mske an array in bourne shell
thanks
Also if one could point me to a good bourne shell site it would be great.
Bibek
The Bourne shell doesn't support arrays.Quote:> How does one make an array in bourne shell
--
See another pointless homepage at <URL:http://home.pages.de/~naddy/>.
> How does one mske an array in bourne shell
> thanks
> Also if one could point me to a good bourne shell site it would be great.
> Bibek
#!/bin/sh
mth1=Jan
mth2=Feb
mth3=Mar
mth4=Apr
mth5=May
mth6=Jun
mth7=Jul
mth8=Aug
mth9=Sep
mth10=Oct
mth11=Nov
mth12=Dec
# What is the index of the current month (1-12)?
idx=`date +%m`
# What was the index last month?
idx=`expr $idx - 1`
if [ "$idx" -eq 0 ]
then
idx=12 # I get confused doing modulus arithmetic
fi
# Map the new index to a name
#
# Note that eval takes its arguments and treats them as input to
# the shell. This allows us to expand the variable name in two
# stages: the first (as an argument to eval) expands %idx, the
# second (as input to the shell) assigns to monthname the value
# held by the variable with the name compounded from "mth" and
# "$idx". Neat huh?
#
# Would be even better if the shell supported the following:
#
# monthname=${mth$idx}
#
# but nested variable names are not supported
eval monthname=\$mth$idx
echo "last month: $monthname"
--
Regards,
Bruce
+--------------------------------------------------------------------------
| Bruce Fountain NEC Australia - New Product Development |
+--------------------------------------------------------------------------
> How does one mske an array in bourne shell
> thanks
> Also if one could point me to a good bourne shell site it would be great.
> Bibek
1. Convert C shell array to Bourne shell
Hi All,
I am wondering that if anyone knows how to convert the C shell
array to Bourne shell?
Or anyone knows where can I find the code to convert C shell array
to Bourn shell on the web?
# Replace arg6 in array with the partition size
Thank you for your time.
########################################################################### Sophia Cheng 415-336-5067 2. Benchmarks 3. Light Speed Bourne Shell! (was: Bourne shell tricks) 8. Change default whois server 9. Need help on bourne shell arrays... 10. Array and looping in Bourne Shell 11. creating an array in the Bourne shell 12. How do I make/use bourne shell array variables?
Sun Microsystem Computer Company
###########################################################################