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 > 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
does any one know how to solve? mlhazan High Level Programming 14 08-27-2008 03:14 PM
How to solve this akashag22 Shell Programming and Scripting 3 07-21-2007 05:54 AM
Can AWK solve it ??? emon Shell Programming and Scripting 1 02-23-2005 01:07 PM

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 08-28-2008
sreenusola sreenusola is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
Can somebody solve this

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it.
i have written like follows:

#!/bin/ksh
DSTAMP=$(date +"%y%m%d%H%M")
rm $CA_OUT_PATH/ftp_logs/temp
touch $CA_OUT_PATH/ftp_logs/temp
chmod 777 $CA_OUT_PATH/ftp_logs/temp
find $CA_OUT_PATH/*/ftp_out -type f -mtime -200 > $CA_OUT_PATH/ftp_logs/temp
while read line
do
cp -f $line $CA_OUT_PATH/ftp_logs/${line}.$DSTAMP
done < $CA_OUT_PATH/ftp_logs/temp


but its trying to copy the entire path of the file and failing.
I need to copy the only filenames.datestamp after the search

pls look in to this help me out.
  #2 (permalink)  
Old 08-28-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,421
Code:
find /old_path/* -type f -mtime +200 -exec echo {} /new_path/{}$(date +"%y%m%d%H%M") \;
If everithing run as expected replace echo by cp -f

Please read and respect the Simple rules of the UNIX.COM forums:
  #3 (permalink)  
Old 08-28-2008
sreenusola sreenusola is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
sorry i should know the rules.....

the query not giving the expected results,, its copying only datestamp not the filename.datestamp
  #4 (permalink)  
Old 08-29-2008
sreenusola sreenusola is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
can somebody reply to this please
  #5 (permalink)  
Old 08-29-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,748
Code:
find /path/to/old/files -mtime +200 |\
while read file
do
   echo "$file"$(date +"%Y%m%d%H%M")  | read newfile
   cp $file /path/to/new/directory/$newfile
done
  #6 (permalink)  
Old 08-29-2008
sreenusola sreenusola is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
Hello Jim,

Its the same problem
the find query bringing the files with the total directory structure and when trying to copy them with total path as per our logic and code failing to copy entire directory struture for eg see the code and output:

CODE:

#!/bin/ksh
find $CA_OUT_PATH/*/ftp_out -type f -mtime -200 |\
while read file
do
echo "$file"$(date +"%Y%m%d%H%M") | read newfile
cp $file $CA_OUT_PATH/ftp_logs/$newfile
done




Output:

cp: cannot create /d09/out/ofad/ftp_logs//d09/out/ofad/glinf/ftp_out/glinf_xslgliaf.ftp.msg200808291526: No such file or directory
  #7 (permalink)  
Old 08-29-2008
sreenusola sreenusola is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 19
can some body look in to this please
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 02:54 AM.


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