Bash Script
OOzy Pal
oozypal at gmail.com
Thu Jan 11 08:41:45 UTC 2007
The script below check my project directory and adds a new project.
For example if the projects I have are:
000-X
001-Y
runnign the script as
script Z
will add a new project 003-Z
but How about if I do
script Z
again? The script will add another project as 004-Z. I would like to
modify the script so it check if the project already exist them it
should not create a new one. It should create the same project with
the same old number
script Z
should not create 004-Z; no, it should recreate 003-Z again.
thanke you
--------------------------------------
#!/bin/bash
PROJECT=$1
WORKINGDIR="/home/hab/Business/Projects"
cd $WORKINGDIR
# Test for existence of zeroth project
if [ ! -e 000-* ] ; then
Num=0
else
MaxIndex=0
for dir in [0-9][0-9][0-9]-* ;
do
Num=${dir%%-*}
Num=${Num##0}
Prj=${Num##0}
if [ $MaxIndex -lt $Num ]; then
MaxIndex=$Num
fi
done
Num=$((Num+1));
fi
Num=$(printf %03d $Num)
PROJECT=$Num-$PROJECT
mkdir $PROJECT
mkdir $PROJECT/1-Process
mkdir $PROJECT/2-Proposal
mkdir $PROJECT/3-Reg-n-Host
mkdir $PROJECT/4-Resources
mkdir $PROJECT/1-Process/01-Discovery
mkdir $PROJECT/1-Process/01-Discovery/1-Gathering-Information
exit
--
OOzy
Kubuntu-Edgy
More information about the ubuntu-users
mailing list