linux shell编写以日期时间为文件名的脚本

—

#!/bin/sh

a=`date +%Y-%m-%d-%H-%M-%S`
echo $a;

a=`date +%Y-%m-%d-%Hh-%Mm-%Ss`
echo $a;

 

 

#log
MYDATE=`date +%d%m%y`
#append MYDATE to the variable LOGFILE that holds the actual filename of the log
LOGFILE=/root/test_log.$MYDATE
#create the file
>$LOGFILE
MYTIME=`date +%d%R`
LOGFILE2=/root/test_logtime.$MYTIME
#create the file
>$LOGFILE2