Append the time stamp to a file name in Ubuntu

前端 未结 2 1863
时光说笑
时光说笑 2021-02-05 18:37

I have a bash script that I use to backup the contents of a SSD every day however I use the following command in the script to name the file

zip -r ssd-$(date \"         


        
相关标签:
2条回答
  • 2021-02-05 19:06

    Does the following do what you need?

    date "+%b_%d_%Y_%H.%M.%S" 
    
    0 讨论(0)
  • 2021-02-05 19:28

    Add _%H_%M_%S into the date-format string as well. For example, date +%b_%d_%Y_%H_%M_%S produces a string like Oct_07_2012_17_57_36. For a shorter string, consider format %s; eg, date +%s produces a string like 1349654346, the number of seconds since 1970-01-01 00:00:00 UTC.

    0 讨论(0)
提交回复
热议问题