Add date to a filename | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Add date to a filename

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-08-2005
richard1975 richard1975 is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 8 February 2005, 9:38 AM EST
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Add date to a filename

Hi

I want to add the date to a filename in a script I have.

So I want

exp myfile01-FEB-2005.dmp
How do I get the 01-FEB-2005 in there?

Cheers
Rich
Sponsored Links
    #2  
Old 02-08-2005
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
 
Join Date: Feb 2004
Last Activity: 30 November 2011, 9:36 AM EST
Location: Oslo, Norway
Posts: 220
Thanks: 0
Thanked 1 Time in 1 Post
see this link
Sponsored Links
    #3  
Old 02-08-2005
gozer13's Avatar
gozer13 gozer13 is offline
Registered User
 
Join Date: Dec 2004
Last Activity: 12 August 2005, 10:44 AM EDT
Location: Salt Lake City, Utah
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
dt=`date +%d-%b-%Y`
exp myfile.$dt.dmp

the results look like:
myfile.08-Feb-2005.dmp

Last edited by gozer13; 02-08-2005 at 12:50 PM..
    #4  
Old 02-08-2005
thumsup9 thumsup9 is offline
Registered User
 
Join Date: Jan 2005
Last Activity: 3 November 2009, 12:04 PM EST
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
j1=`date | cut -c 5-7,9-10,12-13,15-16`
mv filename.txt filename$j1.txt

or

j1=`date | cut -c 5-7,9-10,25-28`
mv filename.txt filename$j1.txt
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
Get the oldest date based on date in the filename gary_w Shell Programming and Scripting 2 06-02-2011 03:19 PM
date from filename davis77 Shell Programming and Scripting 4 12-17-2010 05:55 AM
Date in filename khestoi UNIX for Dummies Questions & Answers 3 09-16-2008 02:54 PM
Get date from filename icy_blu_blu Shell Programming and Scripting 6 07-15-2008 10:55 PM
filename to contain date rkap Shell Programming and Scripting 4 04-06-2005 08:53 AM



All times are GMT -4. The time now is 09:37 PM.