Question: I want to **find** some files, in a non GNU environment

* in the current directory only
* with extension **\*.ext1** and **\*.ext2**,
* but not **name1.\*** or **name2.\***

The following command works, but may be not efficient, because the shell expands `./*` and **find** can get a huge list of files and directories.

```
find ./* -prune \( -name '*ext1' -o -name '*ext2' \) -a ! \( -name 'name1*' -o -name 'name2*' \)

```

**Update:**

I'm working on AIX, there is no **-maxdepth** option.

Answer: 
With `find`:

```
find . ! -name . -prune \
    \( -name '*.ext1' -o -name '*.ext2' \) \
  ! \( -name 'name1.*' -o -name 'name2.*' \)

```

Using `-prune` is the standard equivalent of GNU's `-maxdepth`. Here it tells `find` not to descend in any directory except `.`.

the `! -name .` makes it also exclude `.` from the selection, so `! -name . -prune` is the standard equivalent of GNU's `-mindepth 1 -maxdepth 1`. For GNU's `-mindepth 1`, you'd write `find . \( -name . -o -prune \)`.

With `zsh`, you can also make it:

```
set -o extendedglob
print -rC1 -- *.(ext1|ext2)~(name1|name2).*(ND)

```

`~` being the and-not operator, and `(D)` to include dot-files.
In your current directory you can use `ls` with `grep` (assuming your file names don't contain newline characters):

```
ls -a | grep -E '\.ext(1|2)$' | grep -vE '^name(1|2)\.'

```