Bash Script
OOzy Pal
oozypal at gmail.com
Tue Oct 24 10:53:55 UTC 2006
Dears,
Here is my script. Everything works ok until I get to project 09, an
error appears;
----ERROR----
/home/hab/mybin/pj: line 15: 08: value too great for base (error token is "08")
/home/hab/mybin/pj: line 16: printf: 08: invalid number
----SCRIPT---
#!/bin/bash
WORKINGDIR="/home/hab/Business/Projects"
PROJECT=$1
MaxIndex=0
for dir in [0-9][0-9]-*;
do
Num=${dir%%-*}
if [ $MaxIndex -lt $Num ]; then
MaxIndex=$Num
fi
done
Num=$((Num+1));
Num=$(printf %02d $Num)
PROJECT=$Num-$PROJECT
mkdir $WORKINGDIR/$PROJECT
exit
I am stuck again.
On 10/24/06, Felipe Alfaro Solana <felipe.alfaro at gmail.com> wrote:
> On 10/23/06, OOzy Pal <oozypal at gmail.com> wrote:
> > What is wrong with my script. The script reads a directory listing
> > which contains projects as:
> >
> > 01-Proj1
> > 02-Proj2
> > 03-Proj3
> >
> > The scripts then extracts the first two digits of the file name,
> > compares it to the first two digits of the next file until it finds
> > the max number which is in the case 03. The script then increment the
> > number (03+1). Next it creates a new project as
> >
> > 04-Proj4.
> >
> > --SCRIPT--
> > #!/bin/bash
> >
> > WORKINGDIR="/home/hab/Business/Projects"
> >
> > PROJECT=$1
> > MaxIndex=0
> > PRJ=`ls $WORKINGDIR`
> > for dir in $PRJ ;
> > do
> > Num=${dir%%-*}
> > if [$MaxIndex -lt $Num]; then
> > MaxIndex=$Num
> > fi
> > done
> >
> >
> > #Num=$((Num+1));
> > #Num=$(printf %02d $Num)
> >
> > #PROJECT=$Num-$PROJECT
>
> What about this one?
>
>
> #!/bin/bash
>
> PROJECT=$1
> MaxIndex=0
> for dir in [0-9][0-9]-*;
> do
> Num=${dir%%-*}
> if [ $MaxIndex -lt $Num ]; then
> MaxIndex=$Num
> fi
> done
>
> Num=$((Num+1));
> Num=$(printf %02d $Num)
> PROJECT=$Num-$PROJECT
> echo $PROJECT
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
--
OOzy
Kubuntu-Dapper
More information about the ubuntu-users
mailing list