The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Zip the files from date Stamp to end date Stamp redlotus72 UNIX for Dummies Questions & Answers 1 12-08-2006 03:29 PM
Date Stamp on new file lweegp Shell Programming and Scripting 14 10-03-2006 08:47 PM
Inserting Date&Time Stamp In Existing Log File shephardfamily UNIX for Dummies Questions & Answers 3 02-24-2006 01:01 AM
ftp copy: preserve source file date stamp cassj UNIX for Dummies Questions & Answers 5 02-16-2005 03:38 PM
File date and time stamp Xenon UNIX for Dummies Questions & Answers 1 10-09-2001 12:58 PM

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

Join Date: May 2005
Posts: 69
creating a new file with date stamp

Hi,

can any one tell me how to achieve this...I will input the path and file name and it should rename it to current date and time...
this is what I tried...
Code:
#! /usr/bin/sh
set -x
cd /info_stg/vul/Scripts
TODAY_DATE_TIME=`date +%Y%m%d%H%M%S`
IN_FILE_PATH=`cat file.txt | awk -F, '{ print $1 }'`
OUT_FILE_PATH=`cat file.txt | awk -F, '{ print $3 }'`
IN_FILE=`cat file.txt | awk -F, '{ print $2 }'`
OUT_FILE=`cat file.txt | awk -F, '{ print $4 }'`
cp ${IN_FILE_PATH}${IN_FILE} ${OUT_FILE_PATH}${OUT_FILE}.${TODAY_DATE_TIME}
chmod 755 ${OUT_FILE_PATH}${OUT_FILE}.${TODAY_DATE_TIME}

file.txt has sourceloc,srcfilename,destloc,destfilename
but I want it different way I should be able to send in the name and location as input
like...
script_change_File_Name.sh < /path/for/src/file.txt and this should give me file.txt.todaysdatetime

please advise.

Thanks,
Reply With Quote
Forum Sponsor
  #2  
Old 02-28-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
Code:
#!/bin/ksh
 mv $1 $1`date +%Y%m%d%H%M%S`
Reply With Quote
  #3  
Old 02-28-2006
Registered User
 

Join Date: May 2005
Posts: 69
it worked thanks...
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 10:10 PM.


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