Bash Script
Ouattara Oumar Aziz
wattazoum at gmail.com
Thu Jan 11 11:28:15 UTC 2007
OOzy Pal :
> 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.
>
Are you sure you want to recreate it ? I think you may just cancel since
it already exists. Anyway that's your script :)
try that one
# first create dirs for test
wattazoum at wattazoum-laptop:~$ file=MyTest
wattazoum at wattazoum-laptop:~$ mkdir 230-$file
wattazoum at wattazoum-laptop:~$ mkdir 240-pre$file
wattazoum at wattazoum-laptop:~$ mkdir 231-
wattazoum at wattazoum-laptop:~$ mkdir 231-{$file}sup
# here is the test
wattazoum at wattazoum-laptop:~$ ls | grep [0-9][0-9][0-9]-$file$
You can put it in a var and do whatever you want.
More information about the ubuntu-users
mailing list