Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving directories/files based on creation date

Status
Not open for further replies.

mwesticle

Programmer
Joined
Nov 19, 2003
Messages
51
Location
US
I need to write a script that will look in a specific directory, and look at all of the subdirectories, and, based on creation date of the subdirectory, write all the subdirectories' files out to a list. I know how to write a script, I just need to know if the whole "mtime" command will work with directories, too. Or if there is a better way to do it. Anyone? Thanks for any advice.
 
Unix don't keep trace of creation time, but:
Code:
change time
the inode data has changed
Code:
modification time
the file data has changed
Code:
access time
the file data has been read
Do a
Code:
 man find
for -atime, -ctime and -mtime options.


Hope This Help
PH.
 
OK, so the "find" command will work. But then my main problem will be to get the find command to search through subdirectories when I don't know their names. For example, say I have three directories:

/testdir1/subdir1
/testdir1/subdir2
/testdir1/subdir3

How do I get the find command to list the appropriate files, based on age, contained within 'subdir1, 'subdir2', and 'subdir3', if I don't know these directories' names? Know what I mean???
 
The command
Code:
 find /testdir1 -type f -mtime +7
will recursively descends the directory hierarchy for /testdir1.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top