Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to find all old directories in current directory.
find in AIX does not provide -maxdepth parameter.
There is only -depth and -prune parameters.
It is possible to write something like following:

find ./* -type d -mtime +31 -prune

But it will not work if current directory is empty.
What is the correct way to find all old directories in current directory only, not in all sub-directories of the current directory?

share|improve this question
What exactly do you want to do? Starting your find at '.' (not './*') should be enough. – vonbrand Jan 30 '13 at 21:45
"." will not work if to use -prune parameter. I need to find old directories in current directory only, not in all subdirectories of current directory. – Vladimir Bezugliy Jan 30 '13 at 21:49
up vote 3 down vote accepted

What I believe you likely want is something more like:

find . -not -name . -type d -prune -mtime +31

This will list the immediate directories in current directory older than 31 days. Adding the -not -name . means that the current directory (root of the tree) will already be 'false' before it gets to the -prune action; all the other directories will be pruned.

share|improve this answer
I did not know about -not argument. I am not sure that this will work in AIX, but I checked it now in online Linux emulator and it works as I need. Thank you. – Vladimir Bezugliy Jan 30 '13 at 22:06
-not is not standard, use ! instead which is. – Stéphane Chazelas Jan 30 '13 at 22:09
find . ! -name . -prune ... which says to “prune” (don't descend into) any directories except “.”. content.hccfl.edu/pollock/unix/findcmd.htm – Vladimir Bezugliy Jan 30 '13 at 22:44
But why following command does not work? find /tmp/dir ! -name /tmp/dir -type d -prune – Vladimir Bezugliy Jan 31 '13 at 9:42
The -name takes a single pathname component and should not have a '/' in the argument, hence it would match nothing. You would have to use either -path or be a little smarter about which 'dir' to select. – Arcege Jan 31 '13 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.