Operating System - HP-UX
1822035 Members
3568 Online
109639 Solutions
New Discussion юеВ

Re: using the FIND command to move files

 
SOLVED
Go to solution
Mark Harshman_1
Regular Advisor

using the FIND command to move files

hello
i have a large directory with over 800,000 files in it. I am wanting to move all files older then 30days to another directory. I am trying to use the FIND command, but am not having tons of luck. Any help would be appreciated. This is on a HPUX 11.i server. thanks
Never underestimate the power of stupid people in large groups
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: using the FIND command to move files

Something like this should be close:

cd to desired source directory:

find . -mtime +30 -type f -exec mv {} /xxx/yyy/ \;

Before doing this command, I would substitute a "safe" command like ls -l in the -exec clause to get your criteria just right.

find . -time +30 -type f -exec ls -l {} \;
If it ain't broke, I can fix that.
Sundar_7
Honored Contributor

Re: using the FIND command to move files

cd /huge-directory
find . -mtime +30 -exec mv {} /destination \;
Learn What to do ,How to do and more importantly When to do ?
RAC_1
Honored Contributor

Re: using the FIND command to move files

I would as follows.

touch -t "time_30_days_back" somefile
find /dir -type f ! -newer "somefile" -exec ll -d {} \;
This give list and now move it by adding -exec mv {} /somedir/. or afterwards.

This will also do it.

find /dir -type f -ctime +30 -exec mv {} /somedir/. \;

Anil
There is no substitute to HARDWORK
Dani Seely
Valued Contributor
Solution

Re: using the FIND command to move files

Hey Mark, try this ... this will work:

# find -ctime +30 -exec mv {} \;
Together We Stand!
Dani Seely
Valued Contributor

Re: using the FIND command to move files

WOW! When I opened up your question there were no responses and by the time I typed in my instructions 3 other people had submitted their answers! This forum is awesome!

Sorry ... back to what I was going to say ...
several people used different time options in their find command and I wanted to help you understand the differences:

-atime is for the files access time

-ctime is for the files changed time

-mtime is for the files modified time

Play with the command options by using ls rather than mv until you get the desired result. Hope this clears things up.
Together We Stand!