tags:

views:

84

answers:

2

Script runs fine in Solaris and Linux just not on the crippled MAC -- thus no build environment

#!/bin/bash
var0=1 
LIMIT=60 
mkdir Application 
cd Application 
while [ "$var0" -lt "$LIMIT" ] 
do 
mkdir "$var0"; 
cd $var0;
    for i in $(seq 1 8192); 
    do mkdir "${i}";
    cd "$i";
    dd if=/dev/urandom of=a bs=4096 count=1 > /dev/null 2>&1;
        mkdir "${i}"; 
        cd "$i"; 
        dd if=/dev/urandom of=a bs=4096 count=1 > /dev/null 2>&1;
            mkdir "${i}"; 
            cd "$i"; 
            dd if=/dev/urandom of=a bs=4096 count=1 > /dev/null 2>&1;
                               cd ..;
                          cd ..;
                     cd ..;
                      done
                 cd ..;
      var0=$((var0 = 1));
         echo "$var0";
        date;
+2  A: 

So the answer would appear to be:

  1. Avoid being inflammatory in questions, and read the formatting help, especially when it didn't work the first time! ;-)

  2. Increment var0 correctly (e.g., ((var0++)), ((var0 += 1)), var0=$((var0 + 1)), let "var0=$var0 + 1", etc. instead of var0=$((var0 = 1));)

  3. Terminate the while loop.

Made this a CW because it really was a community effort (I frankly didn't even bother to read the script at first, but then Ignacio's comments made me take a look).

T.J. Crowder
`var0=$((var0 + 1))` or `((var0 += 1))` or `((var0++))` all work so the OP's version may have been a typo.
Dennis Williamson
@Dennis: Thanks, updated the answer. I assume the OP directly copy-and-pasted the script rather than reyping it!
T.J. Crowder
A: 

I don't believe OS X has seq, so you'll have to use jot, write a seq function, or use C-style for loops:

for ((i=1; i<=8192; i++))
Dennis Williamson