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
Using Rename to move files snufse UNIX for Dummies Questions & Answers 1 04-09-2008 09:57 AM
Find, Append, Move & Rename Multiple Files Trapper Shell Programming and Scripting 5 08-30-2007 04:39 AM
trying to rename the files in dir hankooknara Shell Programming and Scripting 8 07-02-2007 12:36 AM
Move and rename files in seq. with padded digits rocinante Shell Programming and Scripting 9 06-09-2007 07:37 PM

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

Join Date: Feb 2006
Posts: 66
Move files and rename ??

1. If I have a file-yyyymmdd.dat in a directory DATA1, then how do I move this file to directory DATA2 and the file name change to file-yyyymmdd.dat.currenttime

I can manual do this
$mv fileA-yyyymmdd.dat ./DATA2/fileA-yyyymmdd.dat.`date +%Y%m%d%H%M%S`
but how do I move all of the files in this directory to new DATA2 and rename it with an extension currenttime like file-yyyymmdd.dat..`date +%Y%m%d%H%M%S`

I dont want to do mannual one by one .

2. If I want to move all file older than file-20060320.dat to DATA2 then what should I do with korn shell.
Thanks .
Reply With Quote
Forum Sponsor
  #2  
Old 03-22-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
Quote:
Originally Posted by sabercats
1. If I have a file-yyyymmdd.dat in a directory DATA1, then how do I move this file to directory DATA2 and the file name change to file-yyyymmdd.dat.currenttime

I can manual do this
$mv fileA-yyyymmdd.dat ./DATA2/fileA-yyyymmdd.dat.`date +%Y%m%d%H%M%S`
but how do I move all of the files in this directory to new DATA2 and rename it with an extension currenttime like file-yyyymmdd.dat..`date +%Y%m%d%H%M%S`

I dont want to do mannual one by one .
one way.....
Code:
for file in *.dat
do
   mv "${file}" ./DATA2/"${file}".`date +%Y%m%d%H%M%S`
done
Quote:
Originally Posted by sabercats
2. If I want to move all file older than file-20060320.dat to DATA2 then what should I do with korn shell.
Thanks .
man find
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 09:59 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