Hi all,
I'm doing a simple backup shell script,
I want to create a tarball filename like ${DIR}_${DATE}${PN}.tgz
PN must be a two digit progressive number but I have some problems with
the first zero.
#!/bin/sh
DATE=`date '+%Y%m%d`
PN=00
VHOST=/www/vhosts/www.domain.tld
while [ -f $VHOST/backup/htdocs_${DATE}${SERIAL}.tgz ] ; do
PN=`expr $PN + 01`
done
tar -zcf $VHOST/backup/htdocs_${DATE}${PN}.tgz -C $VHOST htdocs
#EOF
Then i try to some backup
$ ./backup.sh ; ./backup.sh ; ./backup.sh
$ ls -1 htdocs*
htdocs_2005021200.tgz
htdocs_200502121.tgz
htdocs_200502122.tgz
So, as you can see the PN is only one digit.
00
1
2
but must be
00
01
02
There is anyone that know how to do it?
Thanks in advance and sorry for my english,
Federico.