Linux. Create a file where the file name is the current date
Written by Guillermo Garron
Date: 2013-01-30 20:11:13 00:00
If you need to create a file where the file-name or at least part of it is the current system name you can use this format.
touch file-`date +%F_%T`.txt
This is useful if you are creating reports daily, and you do not want to override them. Suppose you are backing up your MySQL database.
mysqldump -u user --opt some_database > /tmp/some_database-`date +%F_%T`.sql
If you make a cron job to backup your database every day at 23.59 you will have after some days.
- some_database-2013-01-30_23:59:01.sql
- some_database-2013-01-29_23:59:01.sql
- some_database-2013-01-28_23:59:01.sql