Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-07-2004, 03:22 PM   #1
Registered: May 2004
Posts: 75

Rep: Reputation: 15
howto create a file based on date in bash

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?

Old 05-07-2004, 03:24 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 65
I tend to use:
date +%F_%T

Which gives:

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.
Old 05-07-2004, 04:54 PM   #3
Registered: May 2004
Posts: 75

Original Poster
Rep: Reputation: 15
thx david.. that helped


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get file modification date/time in Bash script cmfarley19 Programming 16 04-15-2015 07:25 PM
Filenames based on the date yilez Linux - Newbie 5 11-19-2005 11:11 PM
Create a text file using Bash Boffy Programming 5 03-14-2005 10:06 PM
howto create a torrent file? UltimatePower Linux - Software 7 02-08-2005 12:12 PM
Set name of tar file as date using bash otisthegbs Linux - Software 5 12-18-2003 04:34 PM

All times are GMT -5. The time now is 04:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration