您的位置:首页 > 运维架构 > Shell

【转】How to append current date and timestamp to filename in shell script

2014-01-27 21:46 471 查看
$ date +"FORMAT"

now=$(date +"%Y-%m-%d-%S")
filename="my_program.$now.log"
# example filename: my_program.2012-01-23-47.log

now=$(date +"%Y.%m.%d.%S.%N")
filename="my_program.$now.log"
# example filename: my_program.2013.01.23.44.364617000.log

now=$(date +"%s")
filename="my_program.$now.log"
# example filename: my_program.1358995092.log
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: