Thursday, May 17, 2012

Solaris UNIX Case-Insensitive Find File Search

I'd like to match all filename like foo.c, FOO.C, fOO.c, Foo.C and so on using find command under UNIX. How do I do a case-insensitive find search under Sun Solaris / OpenSolaris UNIX systems?

GNU find command has -iname option which is like -name, but the match is case insensitive. For example, the patterns fo* and F?? match the file names Foo, FOO, FoO etc.

How do I do a case-insensitive find under Solaris UNIX?

However, -iname option is not part of Sun Solaris UNIX find command. You can try following syntax under Solaris:
find . -print | grep -i "pattern"
find . -type f -print | grep -i "filename" # match files only
find . -type f -print | grep -i "*.c"
find . -type f -print | grep -i "foo.c"
find . -type d -print | grep -i "dirname" # match dirs only
find . -type d -print | grep -i "directory-name"

Another option

You can install GNU/find under Solaris.

No comments:

Post a Comment