Equivalent maxdepth for find in AIX

You'd want:

find dir/. ! -name . -prune -type f -name filemask

Or:

find dir ! -path dir -prune -type f -name filemask

To find the regular files called filemask in dir without searching in sub-directories of dir.

With find dir ! -name dir -prune, you'd have issues if there was a dir/dir directory.

The dir/. approach works around that because find will not come across any other file called . than that dir/. file passed as argument.

The -path approach works around it by looking at the file path of the files (as opposed to just the name), -path dir will match on dir, but not on dir/dir (so dir will be the only directory it will not prune). -path may not be available in older versions of AIX though.

More generally, for the standard equivalent of GNU's -maxdepth n, see Limit POSIX find to specific depth?


In AIX you can use -prune option.

find ./* -prune

Tags:

Find

Aix