LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-18-2002, 10:05 AM   #1
frankietomatoes
Member
 
Registered: Oct 2002
Posts: 44

Rep: Reputation: 15
Appending current date and time to a file


Hi,

I want to append the current date and time to a file from a script.

How is this magic done.

Checked for environment variables like $TIME or $DATE but no luck.

Thanks in advance
 
Old 11-18-2002, 10:08 AM   #2
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 55
simple
echo `date`>>filename_to_append_to
won't work?
you might as well peruse man date for detailed format of the date that you can manipulate
 
Old 11-18-2002, 10:41 AM   #3
frankietomatoes
Member
 
Registered: Oct 2002
Posts: 44

Original Poster
Rep: Reputation: 15
Should have made it clear.

I want to append to the filename not the file itself.

Looked at the man page though.

the idea is I have compiled files that I want named by time.
 
Old 11-18-2002, 11:52 AM   #4
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
Try

# cat arq > "arq-`date`"

there's also a lot of format's this date exit could assume, to see then check his options (%):

# man date
 
Old 11-18-2002, 01:58 PM   #5
frankietomatoes
Member
 
Registered: Oct 2002
Posts: 44

Original Poster
Rep: Reputation: 15
# cat arq > "arq-`date`" doesn't work, cats my 5 meg file!!!

tried mv filename.sh "filename-'date'.sh"

just renames it to filename-date.sh.

Thanks though
 
Old 11-18-2002, 02:09 PM   #6
leed_25
Member
 
Registered: Jul 2002
Location: san francisco
Distribution: freebsd
Posts: 102

Rep: Reputation: 17
Hers's a little alias which I use in the bash shell:

Code:
alias otag="date +-%Y-%m%d-%H%Mh%S"
It comes in handy for creating files with timestamps in their names. Like this, for instance:

Code:
$ script file`otag`
Script started, output file is file-2002-1118-1207h49
$ ./configure
                    [. . .]
$ make && make install
                    [. . .]
$ ^D
Script done, output file is file-2002-1118-1207h49
now all of the configuration and make output is in a timestamped file where it can be analysed.

Last edited by leed_25; 11-18-2002 at 02:12 PM.
 
  


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 On
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
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
Question about getting the date/time information from a file shazam75 Linux - General 1 10-31-2004 07:54 AM
Setting environment variable to current date/time nafan Programming 1 08-23-2004 09:04 PM
Where can I look for the config file for modified date and time ForumKid Linux - General 1 09-19-2003 08:05 AM


All times are GMT -5. The time now is 07:17 PM.

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