Operating System - HP-UX
1833730 Members
2292 Online
110063 Solutions
New Discussion

Re: command to find the directory modification date

 
SOLVED
Go to solution
sheevm
Regular Advisor

command to find the directory modification date

Hi All,

can someone tell me what is the best command to use to get the list of the directories that are not modified from the last 30 days?

HP-UX--11.23

Thanks
be good and do good
11 REPLIES 11
James R. Ferguson
Acclaimed Contributor

Re: command to find the directory modification date

Hi:

# find /path -type d -mtime +30

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: command to find the directory modification date

To answer you question literally,

find / -type d -mtime +30

However this may be a question of you not meaning precisely what you are saying; it depends upon whether you mean has the directory been modified in the last 30 days or have the contents of the directory been modified in the last 30 days. It also might depend upon do you mean "changed" or "modified" in UNIX-speak. Those are synonyms in English but not in UNIX.
If it ain't broke, I can fix that.
sheevm
Regular Advisor

Re: command to find the directory modification date

Thanks for the help. This command is listing the sub directories also. I am only interested in the parent directories.

for ex:

./2007-04-23-------I only need this
./2007-04-23/dladb07
./2007-04-23/dladb07/00-00

Thanks
be good and do good
James R. Ferguson
Acclaimed Contributor

Re: command to find the directory modification date

Hi (again):

# find /tmp -type d -mtime +30 -path "/tmp/*"

# cd /path
# find . -type d -mtime +30 -path "./*"

Regards!

...JRF...
sheevm
Regular Advisor

Re: command to find the directory modification date

James,

The path is not working. I do not get anything if I type

cd /home/raji
find ./ -type d -path /home/raji
or
find ./ -type d -path "/home/raji/*"

(i expect just /home/raji/temp)

if I type

find ./ -type -d

i get

/home/raji/temp
/home/raji/temp/test1
/home/raji/temp/test/test1


I checked man pages did not see any syntax problem in my command.

Thanks
be good and do good
Sandman!
Honored Contributor

Re: command to find the directory modification date

>The path is not working. I do not get anything if I type

>cd /home/raji
>find ./ -type d -path /home/raji
>or
>find ./ -type d -path "/home/raji/*"

That's because the path args are missing the leading period whereas your search path is "./" i.e. period followed by slash. Change your find stmt to...

find ./ -type d -path "./home/raji/*"
A. Clay Stephenson
Acclaimed Contributor

Re: command to find the directory modification date

cd /home/raji
find ./ -type d -path /home/raji

Note that you are specifying a relative path as your starting directory but specifying an absolute path as your -path pattern.

find . -type d -mtime +30 ! -path './*/*'

should find only the 1st level directories under the CWD that have not been modified in 30 days.
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: command to find the directory modification date

Overlooked the fact that you were cd'ed into the "/home/raji" directory. So instead use the find(1) command below:

# cd /home/raji
# find ./ -type d -path "./*"
James R. Ferguson
Acclaimed Contributor

Re: command to find the directory modification date

Hi (again):

Oops, sorry, I should have written something like:

# cd /tmp && find . -type d -mtime +30 ! -path "./*/*"

...to find on the directories under '/tmp' that have not been modified in the last 30-days. If you wanted those modified *during* the last 30-days, change +30 to -30.

Regards!

...JRF...
Arturo Galbiati
Esteemed Contributor
Solution

Re: command to find the directory modification date

Hi Kesh,

find . -type d -mtime +30 -prune

This shows only directories under your directory.

HTH,
Art
sheevm
Regular Advisor

Re: command to find the directory modification date

Hi Galbati,

It worked

find with -prune.

Thanks to all of you!!

be good and do good