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

时间:2023-03-09 09:21:47
【转】How to append current date and timestamp to filename in shell script

$ 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