If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > shell script for copying and adding date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-07, 08:24
luki123 luki123 is offline
Registered User
 
Join Date: Mar 2007
Posts: 3
shell script for copying and adding date

Hello everyone, can somebody help me making this script:
To copy one file from one directory to another and to add the current date and time the copyied file??
Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-19-07, 03:13
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
cp $onedir/$filename $anotherdir/${filename}_`date '+%Y%m%d_%H%M%S'`
Reply With Quote
  #3 (permalink)  
Old 03-27-07, 04:31
krishna.reddy krishna.reddy is offline
Registered User
 
Join Date: Jan 2006
Posts: 5
Lightbulb

DATE=`date '+%Y%m%d_%H%M%S`
cp $onedir/$filename $anotherdir/${filename}_${DATE}

If the date contains any '/' then there can be problem in file creation. So, careful when using date like `date +%D`
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On