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
To convert multi format file to a readable ascii format gaur.deepti UNIX for Dummies Questions & Answers 5 03-25-2008 12:03 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 05:42 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-27-2006 08:30 PM
file date format ludenso UNIX for Advanced & Expert Users 4 04-30-2006 06:01 AM
Converting the File Creation Date to a new format barney_clough UNIX for Dummies Questions & Answers 1 06-12-2002 04:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-07-2005
Registered User
 

Join Date: Sep 2005
Posts: 2
Question Add Date format to a file.

Hi,

I need to copy a file from one directory to another and need to add the current date at the end of my file in the new dir. Please provide me the cmd that I can use.

I have a file abc.dat in dir SD/Files. I need to copy this file to dir SD/Files/Latest and the file name should have date with current time stamp at the end like abc.dat_10/07/2005 12:30:22.

Thanks,
Sarath.
Reply With Quote
Forum Sponsor
  #2  
Old 10-07-2005
Registered User
 

Join Date: Sep 2005
Posts: 36
file_name="abc.dat_"
YYYYMMDDTIME="`date '+%d/%m/%Y %H:%M:%S'`"
file_name=${file_name}_${YYYYMMDDTIME}
echo $file_name
Reply With Quote
  #3  
Old 10-07-2005
Registered User
 

Join Date: Sep 2005
Posts: 2
Hi Akrithi,

I am new to scripts..

I ran the PERL script that you gave me..

my $src_file_name="/dba58/d039/powerdev/staging/Devl/SrcFiles/CRMPS01/receivables/crmps_dly_recv_file_detail.dat" ;
my $tgt_file_name="/dba58/d039/powerdev/staging/Devl/SrcFiles/CRMPS01/receivables/TEMP";
my $YYYYMMDDTIME="`date '+%d/%m/%Y %H:%M:%S'`" ;
file_name=${tgt_file_name}_${YYYYMMDDTIME};
#echo $file_name
cp src_file_name file_name;



I got errors when I ran this..

Script name : script_copy.pl

[/dba58/d039/powerdev/staging/Devl/Scripts/CRMPS01]>perl script_copy.pl
Bareword found where operator expected at script_copy.pl line 4, near "${tgt_fil
e_name}_"
(Missing operator before _?)
syntax error at script_copy.pl line 4, near "${tgt_file_name}_"
Execution of script_copy.pl aborted due to compilation errors.
[/dba58/d039/powerdev/staging/Devl/Scripts/CRMPS01]>

Can u tell me how to resolve this..?
Reply With Quote
  #4  
Old 10-07-2005
Registered User
 

Join Date: Oct 2002
Posts: 676
It's a shell script, not a PERL script.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:03 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