Bash Script

OOzy Pal oozypal at gmail.com
Mon Oct 23 10:41:59 UTC 2006


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



-- 
OOzy
Kubuntu-Dapper




More information about the ubuntu-users mailing list