Operating System - HP-UX
1837159 Members
2860 Online
110112 Solutions
New Discussion

How do I know if a file has been modified in a directory

 
SOLVED
Go to solution
Henry Chua
Super Advisor

How do I know if a file has been modified in a directory

Hi Guys,

Merry christmas to all!!! ^_^

Just want to find is that any way to find out if a directory contain files that has been modified without goin into the directory itself?

thank u!!

Henry
5 REPLIES 5
Tony Constantine
Frequent Advisor
Solution

Re: How do I know if a file has been modified in a directory

Hi Henry,

You could try:

find "directory" -mtime +1 (see man find)

Georg Tresselt
Honored Contributor

Re: How do I know if a file has been modified in a directory

ls -l
http://www.tresselt.eu
MarkSyder
Honored Contributor

Re: How do I know if a file has been modified in a directory

Hi Henry - Merry Christmas to you too.

When a file in a directory is modified the timestamp on the directory is updated.

If you type:

ll -tr

you will see a listing of files/directories in the order in which they were last amended. The r means reverse order, which will place the most recently amended files/directories at the bottom.

If you only want to check one directory you could use:

ll|grep dirname

where dirname is the name of the directory you want to check.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Paul Torp
Regular Advisor

Re: How do I know if a file has been modified in a directory

find /directory -mtime + (hours from now)

Then u can i u please add a -exec rm {}\;

if u e.g want to remove old logfiles.

tips.. always test with ls insted of rm before deleting files. (at least the first time)

-paul
"sendmail is kind of fun..."
Henry Chua
Super Advisor

Re: How do I know if a file has been modified in a directory

thanks