Convert C shell array to Bourne shell

Convert C shell array to Bourne shell

Post by Sophia Che » Sun, 17 Aug 1997 04:00:00



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.

################################################################################
Sun Microsystem Computer Company

Sophia Cheng                        415-336-5067

################################################################################

 
 
 

1. Light Speed Bourne Shell! (was: Bourne shell tricks)

                              WARP SPEED TESTS!

For a light-speed bourne shell script, I just found out a really cool trick:
        if [ "$var" = "condition" ]; then list; fi
becomes:
        case "$var" in "condition") list;; esac

Take this example, two scripts:
        if.sh:
                for x in `jot 1000`; do
                        if [ $x = 1000 ]; then echo "Done"; fi
                        done
        case.sh:
                for x in `jot 1000`; do
                        case $x in 1000) echo "Done";; esac
                        done

("jot" is just some weird util we have here that prints out numbers)
Now take a look at the runtimes (on a DECstation/240 with not much load):
#0 /tmp/JAMtmp> time sh case.sh
                real    0m0.53s
                user    0m0.11s
                sys     0m0.05s
#0 /tmp/JAMtmp> time sh if.sh  
 ^--return code of last cmd in prompt ;-)
                real    0m32.43s
                user    0m1.95s
                sys     0m16.80s
So, case instead of test is:
real:   61 times faster
user:   18 times faster
sys :   31 times faster

...So use case instead of if whenever you can! (just remember the case will
interpret your condition as a pattern!)

--

  n  r    
  a JAMax  "Thou shalt not kill...  Thou shalt not steal...
  h o   w   Thou shalt not covet thy neighbour's...ass nor any
  tan lle   thing that is thy neighbour's."  --Bible

2. Wanted: Source of trace or examples for ptrace()

3. Bourne Shell compatible shells (was: Request: which shells)

4. Promise SuperTRAK66 RAID Controller

5. 1D-Arrays in Bourne shell

6. Ports 6000 and 8000

7. array in bourne shell

8. Red Hat 5.2 Install Instructions

9. Need help on bourne shell arrays...

10. array in bourne shell

11. Array and looping in Bourne Shell

12. creating an array in the Bourne shell

13. How do I make/use bourne shell array variables?