美文网首页
生成以date系统日期为结尾的文件 2019-02-19

生成以date系统日期为结尾的文件 2019-02-19

作者: Sean松涛 | 来源:发表于2019-02-19 22:29 被阅读0次

    Linux下直接运行date的结果:

    [root@mdc3 edlm]# date
    2019年 02月 19日 星期二 22:27:35 CST
    [root@mdc3 edlm]# date +%Y_%m_%d_%H_%M
    2019_02_19_22_27
    [root@mdc3 edlm]# 
    

    date +%Y%m%d%H%M 可以得到指定格式的输出:

    这样我们就可以引用date的输出了,使用$(date +...)

    [root@md]# echo hello > test.txt
    [root@md]# cp test.txt test_$(date +%Y_%m_%d_%H_%M).txt
    [root@md]# ls test*
    test_2019_02_19_22_24.txt  test.tmp  test.txt
    

    相关文章

      网友评论

          本文标题:生成以date系统日期为结尾的文件 2019-02-19

          本文链接:https://www.haomeiwen.com/subject/cjeqyqtx.html