Linux - Create file with date timestamp, Copy or rename a file with date time stamp
Create file with date timestamp
Creating file with date time stamp
Many times you may need to need to create a file file with date and time stamp. It will be much helpful for the administrator when they have a copy of configuration or other files with date and time timestamp.
Command to create a file with date and time stamp
# touch rename.txt`date +%d%m%y`
touch is a linux command to create a file. Here rename.txt is the file name and date is added to it using the date command. The command is appended using ` LEFT SINGLE QUOTATION MARK, GRAVE ACCENT . It is not the single quote or double quote, it is the special character with the tilde symbol on your keyboard.
copy a file with date and time satmp
# cp copy-date.htm copy-date.htm`date +%m%y`
output for copy file with date
-rw-rw-r-- 1 ramesh ramesh 2 2009-10-13 08:59 copy-date.htm1009Rename a file with date and time satmp
# mv copy-date.htm rename.htm`date +%d%m%y`
output for rename file with date and timestamp
-rw-rw-r-- 1 ramesh ramesh 2 2009-10-13 09:26 rename.htm131009where,
date - is the command %d - date of the month %m - month %y - year %H - time stamp or hour
Here in the above output 13 is the date 10 is the month and 09 is the year. This is how you can create, copy and rename a file with date and timestamp option.
The topic on Linux - Create file with date timestamp is posted by - Math
Hope you have enjoyed, Linux - Create file with date timestampThanks for your time