The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using camcorder tapes to back up files iBot UNIX and Linux RSS News 0 12-20-2007 12:20 PM
Can I back up all the files I work with each day using tar? jo calamine Filesystems, Disks and Memory 2 10-01-2006 06:35 PM
How to remove 15days back old files vidya2006 Post Here to Contact Site Administrators and Moderators 2 05-18-2006 02:41 PM
Script to delete all data from multiple files uni_ajay_r Shell Programming and Scripting 5 03-29-2006 12:05 PM
Bring back removed files Reza Nazarian UNIX for Dummies Questions & Answers 2 07-23-2001 11:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-07-2007
dsravan dsravan is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 188
Back up of multiple data files

I have filesi in a direcotry that start with different names but have dates in the format 01212006. Along with these files there are also files with different dates. What i want to do is copy all the files that have 01212006 in them to 01072007 and move the old files to different directory.

For e.g file of interest : abc.01212006.1.dat
file of no interest abc.01262006.1.dat

I need the file of interest to be copied to abc.01072007.1.dat and then move the old file to diffrerent directory. How can I acheive this?
  #2 (permalink)  
Old 02-07-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Try...
Code:
#!/usr/bin/ksh

date="01212006"
newdate="01072007"

for file in *$date*
do
  [[ -f $file ]] || echo no files && exit 1
  newfile=$(echo $file|sed "s/$date/$newdate/")
  cp $file $newfile
  : etc
done
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0