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?

  • 1
    What exactly do you want to do? Starting your find at '.' (not './*') should be enough.
    – vonbrand
    Jan 30, 2013 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. Jan 30, 2013 at 21:49

1 Answer 1


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.

  • 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. Jan 30, 2013 at 22:06
  • -not is not standard, use ! instead which is. Jan 30, 2013 at 22:09
  • find . ! -name . -prune ... which says to “prune” (don't descend into) any directories except “.”. content.hccfl.edu/pollock/unix/findcmd.htm Jan 30, 2013 at 22:44
  • But why following command does not work? find /tmp/dir ! -name /tmp/dir -type d -prune Jan 31, 2013 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, 2013 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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