How to do Find Command Invert Match in Solaris

by Sasikala on May 14, 2010

Question: I’m using Sun Solaris OS. When I execute the find command, I get “find: bad option -not” as shown below. How do I fix the following error?

find: bad option -not
find: path-list predicate-list" in Solaris SunOS.

Answer: In Linux, find command with -not option is used for inverting the match.

For example:

$ find . -not -name '*.txt'

This command finds all the files and directories which doesnot have .txt at the filename. For more examples, refer our earlier article Mommy, I found it! — 15 Practical Linux Find Command Examples

Now, execution of the above command in Solaris will fail with the “bad option -not” message.

$ find . -not -name '*.txt'
find: bad option -not
find: path-list predicate-list

On Solaris, use ! operator to perform inverse matching as shown below.

$ find . ! -name '*.txt'

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: