date value space prolbem
hi,
my small bash script has a problem, when the date is 10-31, it runs fine, but when it is 1-9 it get problems.
#!/bin/sh
#take the current time's hour value -1, then grep with "Feb 12 13" format.
vH=`date +"%H"`
echo $vH
vD=`date +"%e"`
echo $vD
echo "$vD"
vM=`date +"%b"`
echo $vM
v5="$vM $vD $vH"
echo $v5
#create backup folder by date, only need when you need backup hourly maillog file.
if [ ! -e /home/oiprod/$vD ]
then
mkdir /home/oiprod/$vD
fi
cp -p /home/oiprod/smtp_mail_log/maillog /home/oiprod/$vD/maillog${vH}
here is the error message:
[oiprod@admin1 oiprod]$ ./maillog2.sh
12
3
3
Mar
Mar 3 12
./maillog2.sh: [: /home/oiprod/: binary operator expected
cp: copying multiple files, but last argument `3/maillog12' is not a directory
Try `cp --help' for more information.
anyone knowns why?
thanks!
jimmy
|