LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   howto create a file based on date in bash (https://www.linuxquestions.org/questions/linux-newbie-8/howto-create-a-file-based-on-date-in-bash-179045/)

rohan208 05-07-2004 02:22 PM

howto create a file based on date in bash
 
Hello,
I'd like to know how to create a file depending one current day of the month.
I assume something like
$ vi /home/xyz/report$DATE.txt

where $DATE needs to be teh current date in any format. Any ideas?
thx

Rohan

david_ross 05-07-2004 02:24 PM

I tend to use:
date +%F_%T

Which gives:
2004-05-07_20:23:16

So try:
vi myfile_`date +%F_%T`.txt

Using backticks like this you can put it in any command such as a tar command for backups etc.

rohan208 05-07-2004 03:54 PM

thx david.. that helped
:D


All times are GMT -5. The time now is 03:36 AM.