shell时间,shell创建文件,linux shell编写以日期时间为文件名的脚本学习笔记 (转)
载自:http://www.justwinit.cn/post/3702/
shell时间:
a=`date +%Y%m%d`
echo $a;
echo $a;
# sh data.sh
20101028
20101028
#!/bin/sh
#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
#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
会生成俩文件:
ls /root/test_log.281010
/root/test_log.281010
ls /root/test_logtime.2819:26
/root/test_logtime.2819:26