Click to See Complete Forum and Search --> : A BASH Scripting Question


a31modela
05-26-2005, 04:58 PM
Hello All,

I am writing a script that will create multiple symbolic links based upon which type is needed. The resulting sym link must be named as follows : str7966rgXXX ( where XXX is a 3 digit number from 101 thru 111)

Script I wrote is below but my problem is that I can't get the links named correctly. Instead of having rg101, 102, 103.....110,111 , I get 11, 12,13...18,19,110,111.

How can I maintain the correct numbering with what I have in my script by maintaining the value of x as a 2 digit number? I thought I could use typeset or declare but haven't figured out what configuration would work.


# !/bin/bash

# sf - 5/26/05

x=01

echo " Enter image type store or warehouse , followed by [ENTER]:"

read image
if [ $image = store ]
then

until [ ${x} = 12 ]
do

ln -sf client_golden.master str7966rg1${x}
x=$[$x + 1]
done

fi

if [ $image = warehouse ]
then

until [ ${x} = 12 ]
do

ln -sf GreenScreenwSource.master str7966rg1${x}
x=$[$x + 1]
done

fi

Thanks,

Steve

a31modela
05-26-2005, 05:13 PM
FIxed the issue, instead of making x=01, I made x=101 & then increment up by 1.

Its the obvious stuff that kills me.......

Thanks !