Creating file with date/timestamp in it | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Creating file with date/timestamp in it

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-04-2002
ccpjr29 ccpjr29 is offline
Registered User
 
Join Date: Jan 2002
Last Activity: 29 January 2002, 3:38 PM EST
Location: Ontario, Canada
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Creating file with date/timestamp in it

I need to create a file through a c-shell script which contains only the date and time that the file was created. Does anyone know a simple way to do this?

Thank you,
Paula
Sponsored Links
    #2  
Old 01-04-2002
thehoghunter
Guest
 
Posts: n/a
If you were looking to place the date and time into an empty file then date '+%m%d%y %H%M%S' > /tmp/yournewfile will work in any shell.

Changing %m%d%y to %m/%d/%y gives 01/04/02 instead of 010402
Sponsored Links
    #3  
Old 01-29-2002
nicfellows nicfellows is offline
Registered User
 
Join Date: Jan 2002
Last Activity: 25 November 2002, 12:46 PM EST
Location: Newcastle, UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question date in filename

Can anyone help me with creating a file from a shell script with the date in its name eg :

'log-2002-01-28.log'

Thanks in advance

Nic
    #4  
Old 01-29-2002
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
 
Join Date: Nov 2001
Last Activity: 23 October 2011, 10:07 PM EDT
Location: Brisbane, Australia
Posts: 509
Thanks: 7
Thanked 0 Times in 0 Posts
To create a file named ... 'log-2002-01-28.log'

cat somefile > "log-`date '+%Y-%m-%d'`.log"
Sponsored Links
    #5  
Old 01-29-2002
nicfellows nicfellows is offline
Registered User
 
Join Date: Jan 2002
Last Activity: 25 November 2002, 12:46 PM EST
Location: Newcastle, UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Cheers

Cheers mate,

Ill have a play with that and see if i can get it to work
Sponsored Links
    #6  
Old 01-29-2002
boat73 boat73 is offline
Registered User
 
Join Date: Jan 2002
Last Activity: 6 June 2002, 8:48 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
This will simply create a file.
#!/bin/sh
DATE="`date +%m`_`date +%d`_`date +%y`.log"
touch $DATE
Sponsored Links
    #7  
Old 02-13-2002
sierra_aar sierra_aar is offline
Registered User
 
Join Date: Feb 2002
Last Activity: 17 March 2003, 4:12 AM EST
Location: Small country named: Israel
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Data

boat73,
I tried pasting your code exactly, but it didn't work for me.
I tried more ways, with no luck.

Do u, or some1 else knows of a way it will work for me? I also prefer it in tcsh, if posible.

thanks.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Check if a date field has date or timestamp or date&timestamp machomaddy Shell Programming and Scripting 1 02-25-2012 11:29 PM
To get max/min Date/Timestamp from a file vikanna Shell Programming and Scripting 5 06-15-2011 04:21 AM
finding the previous day date and creating a file with date apple2685 Shell Programming and Scripting 4 05-17-2011 06:21 AM
File renaming with date timestamp Sunitha_edi82 Shell Programming and Scripting 3 08-05-2008 09:04 AM
get a file date/timestamp alex31 UNIX for Dummies Questions & Answers 3 12-22-2005 10:06 AM



All times are GMT -4. The time now is 04:26 PM.