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
rename a lot of files again ajp7701 Shell Programming and Scripting 11 03-31-2008 04:36 PM
rename files help piltrafa UNIX for Dummies Questions & Answers 2 10-04-2007 06:47 AM
trying to rename the files in dir hankooknara Shell Programming and Scripting 8 07-02-2007 12:36 AM
rename many files fsmadi SUN Solaris 4 04-30-2007 08:27 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2002
Registered User
 

Join Date: May 2002
Location: NL
Posts: 5
Lightbulb How to rename files?

How can i rename a file 'x.log' to 'x_20020512 072909.log'

i'm using perl, with system command from a unix web server, and need to timestamp my logs if the above format (filename _ year month day hr min sec .log)
__________________
got msn @ msn1@CompuTel-Systems.com

email to unix.com@CompuTel-Systems.com
Forum Sponsor
  #2 (permalink)  
Old 05-13-2002
annececile's Avatar
Registered User
 

Join Date: Nov 2001
Location: Paris, France
Posts: 42
You can do:
system "mv x.log x_`date +%Y%m%d%H%M%S`";
Be careful, it is not quote but contrequote !!!
It is working for me.
Good luck !!
  #3 (permalink)  
Old 05-13-2002
Cameron's Avatar
Registered User
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 486
Care: "x_20020512 072909.log"
Aviod using spaces within file names if possible.
  #4 (permalink)  
Old 05-13-2002
Registered User
 

Join Date: May 2002
Location: NL
Posts: 5
Unhappy

Quote:
Originally posted by annececile
You can do:
system "mv x.log x_`date +%Y%m%d%H%M%S`";
Be careful, it is not quote but contrequote !!!
It is working for me.
Good luck !!

Used copy&paste for it, but it won't work
__________________
got msn @ msn1@CompuTel-Systems.com

email to unix.com@CompuTel-Systems.com
  #5 (permalink)  
Old 05-13-2002
annececile's Avatar
Registered User
 

Join Date: Nov 2001
Location: Paris, France
Posts: 42
I try this on a SUN OS 5.7.
What is the result or the error ?
If it is only on the date, the best way to adjust this to your system is to do "man date" !!!
Do you try this command in your shell before scripting (without system !!) ?
  #6 (permalink)  
Old 05-13-2002
Registered User
 

Join Date: May 2002
Location: NL
Posts: 5
i don't get an error, the script runs on my ISP's server, but it seems the MV command is'nt working there.... (did try to rename aa to bb: nothing...

i'm using win:XP on my sys, can't test it here

(i'm using MSN, ICQ, AIM and YAHOO! messenger...)
__________________
got msn @ msn1@CompuTel-Systems.com

email to unix.com@CompuTel-Systems.com
  #7 (permalink)  
Old 05-14-2002
annececile's Avatar
Registered User
 

Join Date: Nov 2001
Location: Paris, France
Posts: 42
What is the OS of your ISP server ? Can you do a telnet on it ?
Google UNIX.COM
Closed Thread

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:24 PM.


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

Content Relevant URLs by vBSEO 3.2.0