The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 08-29-2008 01:32 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 01:01 PM
filename in current directory calgone337 Shell Programming and Scripting 2 04-15-2007 11:21 AM
Append filename to datafile Satyagiri UNIX for Dummies Questions & Answers 3 10-12-2006 06:19 AM
Append date to filename hshapiro UNIX for Dummies Questions & Answers 5 04-03-2006 06:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-19-2006
Registered User
 

Join Date: Jul 2006
Posts: 2
Arrow Append current date to filename

In C Shell programming I haven’t successfully been able to append the date in the format mmddyyyy to a filename. I’ve tried the following:

I can print out the date in the correct format: date +%x | sed ‘s/\///g
I can create a variable with the filename: set newfile=changedfiles
I can use the mv command: mv changedfiles.tar “$newfile”

I cannot figure out how to append the current date to the file named in $newfile.
Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 07-19-2006
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
set newfile = "changedfiles`date +%m%d%Y` "
This would give you "changedfiles07192006" set into the variable newfile
Reply With Quote
  #3  
Old 07-19-2006
Registered User
 

Join Date: Jul 2006
Posts: 2
Thanks that worked.
You helped me realize that there is a difference between the symbols ' and `.
Reply With Quote
  #4  
Old 07-20-2006
Registered User
 

Join Date: Jul 2006
Posts: 55
` is used for command substitution.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0