From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25292 invoked from network); 17 Dec 2003 10:58:36 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 17 Dec 2003 10:58:36 -0000 Received: (qmail 25284 invoked by alias); 17 Dec 2003 10:58:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6909 Received: (qmail 25235 invoked from network); 17 Dec 2003 10:58:22 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 17 Dec 2003 10:58:22 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.227.126.204] by sunsite.dk (MessageWall 1.0.8) with SMTP; 17 Dec 2003 10:58:21 -0000 Received: from [172.17.36.7] (helo=erdbeere.use.schlund.de) by mintern1.kundenserver.de with esmtp (Exim 3.35 #1) id 1AWZNk-00057o-00 for zsh-users@sunsite.dk; Wed, 17 Dec 2003 11:58:20 +0100 Received: from luthien by erdbeere.use.schlund.de with local id 1AWZNV-0000d2-00 for ; Wed, 17 Dec 2003 11:58:05 +0100 Date: Wed, 17 Dec 2003 11:58:05 +0100 From: Dominik Vogt To: zsh-users@sunsite.dk Subject: Re: Creating a directory with a date-based name Message-ID: <20031217105805.GC1177@gmx.de> Reply-To: zsh-users@sunsite.dk Mail-Followup-To: zsh-users@sunsite.dk References: <1kc0uvc2je7sklkfapdogigrl93fhhk0p2@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1kc0uvc2je7sklkfapdogigrl93fhhk0p2@4ax.com> User-Agent: Mutt/1.3.28i On Wed, Dec 17, 2003 at 10:45:09AM +0000, zzapper wrote: > > Hi Ya, > > I'm a zsh newbie. > > I have the following bash script, which will create a directory say > 06Dec03 if this directoryy exists then create 06Dec03v2 > > I need to enhance it to create 06Dec03v3,4,5,6 etc. should these > directories exist. > > How would this best be done in zsh? > > dirbackup="c:/backup/mysqlnext/" > cd $dirbackup > eval dat=$(date.exe '+%d%b%y') > > if ! mkdir $dat > then > dat=$dat"v2" > if mkdir $dat > then > echo "created $dat" > fi > fi > cd $dat Like this (untested): dirbackup="c:/backup/mysqlnext/" cd "$dirbackup" eval dat=$(date.exe '+%d%b%y') if ! mkdir "$dat"; then i=1 finished="" while [ -z "$finished" ] && [ "$i" != 9999 ]; do i=$[i+1] dat="${dat}v$i" if mkdir "$dat"; then echo "created $dat" fi done fi cd $dat Ciao Dominik ^_^ ^_^