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
List files created before Noon 2 days prior prismtx Shell Programming and Scripting 3 01-19-2008 12:06 PM
ls latest 4 days or specify days of files in the directory happyv Shell Programming and Scripting 3 01-22-2007 07:16 AM
How to delete files over 30 days GEBRAUN UNIX for Dummies Questions & Answers 2 01-25-2006 01:58 AM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 04:40 AM
removing files that are 60 days old aojmoj Shell Programming and Scripting 5 01-26-2004 02:45 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 05-09-2006
pavan_test pavan_test is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 53
moving files prior to 2 days

Hi All,

I have a question.
i have a directory say /home/pavi/logs

ls -ltr gives all the files in the /home/pavi/logs directory.

i am trying to move only those files existing in this
folder prior to 2 days.

i.e files exiting say May 9th and May 8th remain in this directory
but all the remaining files should be moved to a destination dir
say /hom/pavi

can anyone please suggest me with some ideas.

thanks
pavi
  #2 (permalink)  
Old 05-09-2006
gthokala gthokala is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 21
Smile

This works for moving the files more than 2 days old (2 * 24 hours Change the number accordingly after mtime parameter)
mv `find /home/pavi/logs/*.* -mtime +2 -exec ls {} \;` /home/pavi

Gopinath
  #3 (permalink)  
Old 05-09-2006
roderashe roderashe is offline
Registered User
  
 

Join Date: May 2006
Posts: 6
When I use this for my script I get a bunch of errors. I thought I could use Xargs but I get this:

usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory

Here's my code:

find /home/pavi/logs/ -mtime +21 -exec ls {} \; | xargs mv /home/pavi

Any thoughts? Thanks.
  #4 (permalink)  
Old 05-10-2006
gthokala gthokala is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 21
Did you put the quote in front of find command and close the quote after the semicolon? This statement works fine and move all the files prior to 2 days old.
  #5 (permalink)  
Old 05-10-2006
roderashe roderashe is offline
Registered User
  
 

Join Date: May 2006
Posts: 6
Do I need to use the quotes? I thought I didn't since I was piping to xargs? Thanks!

UPDATE: After putting the backquotes in here's the error I get:

-sh: ./.DS_Store: cannot execute binary file
  #6 (permalink)  
Old 05-10-2006
gthokala gthokala is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 21
Please post exactly what you are typing to move the files.

Try to Copy or make changes to the paths and execute the command below and it should move the files older than 2 days old.

mv `find /home/pavi/logs/*.* -mtime +2 -exec ls {} \;` /home/pavi
  #7 (permalink)  
Old 06-11-2009
Mujtaba khan Mujtaba khan is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 3
Thumbs up move old files ina folder

Hi,

This will help u what i did is to cd inside that area from where i want the results and create a folder log.bkup and move all file more than 7 days into that folder

find . -mtime +7 -exec mv {} log.bkup \;

Reply

Bookmarks

Tags
mtime

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 08:16 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