Find File names with sustitution

Hi All,

Iam trying to find two kinds of files while ignoring rest of the files in a directory

The files are like below

Files to be found
--------------------
perp45560
oerp4556

Files to be ignored
----------------------
oerp4556123450
oerp4556123470

I was trying the following in SunOS 5.10

find /mydir/files -name "[po]erp4556[?]" it is NOT working

if i use

find /mydir/files -name "[po]erp4556*"

it lists the files to be ignored also

if i use

find /mydir/files -name "[po]erp4556[0]"

it lists only "p" kind of files and ignores "o" kind.

the problem is simple while "p" files have a "0" [Read as zero] at the end, "o" files dont have anything. How to write a find command to find both simultaeneously while it should ignore other longer "p" or "o" files.

I would appreciate your help.

Regards

-name only knows shell patterns..

find /path \( -name perp* -o -name oerp* \) -ls

$ ls
oerp4556        oerp4556123450  oerp4556123470  perp45560
$ find . -name 'oerp4556' -o -name 'perp45560'
./perp45560
./oerp4556

If your find supports the regex option:

$find -regextype posix-extended -regex '.*[op]erp45560{,1}'
./oerp4556
./perp45560
  1. With ksh,bash and zsh you can use ksh or extended-globbing, but you can do a recursive search only with the Z-Shell:

[ksh]

$ echo *
oerp4556 oerp4556123450 oerp4556123470 perp45560
$ echo [op]erp4556?(0)
oerp4556 perp45560

[bash]

bash 3.2.25(1)$ shopt -s extglob
bash 3.2.25(1)$ echo [op]erp4556?(0)
oerp4556 perp45560

[zsh]

zsh 4.3.4% setopt kshglob
zsh 4.3.4% echo [op]erp4556(?(0))
oerp4556 perp45560

or recursive:

setopt kshglob
print -l **/[op]erp4556(?(0))

special chars like * ? do not work in brackets , so try this,

find /mydir/files -name "[po]erp4556?"

Here ? is any character, not only 0 and this doesn't glob "oerp4556".