Download your favorite Linux distribution at LQ ISO.
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, 02: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, 02:24 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
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, 03: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 06:25 PM
Filenames based on the date yilez Linux - Newbie 5 11-19-2005 10:11 PM
Create a text file using Bash Boffy Programming 5 03-14-2005 09:06 PM
howto create a torrent file? UltimatePower Linux - Software 7 02-08-2005 11:12 AM
Set name of tar file as date using bash otisthegbs Linux - Software 5 12-18-2003 03:34 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:39 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
Open Source Consulting | Domain Registration