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
deleting file with timestamp jcluvme UNIX for Dummies Questions & Answers 2 01-10-2008 05:59 PM
File timestamp stevefox UNIX for Dummies Questions & Answers 4 12-24-2007 09:14 PM
changing timestamp of a file krishan SUN Solaris 1 05-23-2005 07:50 AM
timestamp of file krisdhar UNIX for Dummies Questions & Answers 4 10-28-2003 06:31 AM
HP-UX lp spooling places doeboy UNIX for Advanced & Expert Users 2 04-10-2002 09:21 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-23-2004
Registered User
 

Join Date: Aug 2003
Posts: 5
Stumble this Post!
Spooling a log file with timestamp

Hi
From shell script i am invoking sqlplus to connect to oracle database and then i spool a csv file as with output. What i want to do is to change the file name with timestamp on it so after spooling finish shell script change file name with time stamp.
can someone help me to do that .

Thanks
UKADMIN
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-23-2004
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Stumble this Post!
Well, if I understand you correctly, this is easy. After your shell script logs into Oracle and runs your sql, then disconects, use a mv command to rename your file.
%T gives a time format inmilitary time like 21:01:54

SPOOL-NAME=blah-blah-blah
NEW-FILE-NAME=$SPOOL-NAME_$(date +'%T').csv


mv $SPOOL-NAME $NEW-FILE-NAME
Reply With Quote
  #3 (permalink)  
Old 03-23-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,243
Stumble this Post!
Use the date command to generate output file name, e.g...

NAME=`date +extract_%Y-%m-%d_%H:%M:%S.csv`
echo output file is $NAME
sqlplus args > $NAME

See man date for formatting
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:09 AM.


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