LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 05-07-2004, 02:22 PM   #1
rohan208
Member
 
Registered: May 2004
Posts: 75

Rep: Reputation: 15
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
 
Old 05-07-2004, 02:24 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
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.
 
Old 05-07-2004, 03:54 PM   #3
rohan208
Member
 
Registered: May 2004
Posts: 75

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


Reply


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 12 01-19-2013 09:37 AM
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


All times are GMT -5. The time now is 09:29 AM.

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