≡ Menu

How to do Find Command Invert Match in Solaris

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'
./509edca2-8636-7542-1845-cafd3cab4c39_header.xml
./68d32b32-8638-7542-0e45-8c374f03f56b_header.xml
./mondbfile.sql

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'
./509edca2-8636-7542-1845-cafd3cab4c39_header.xml
./68d32b32-8638-7542-0e45-8c374f03f56b_header.xml
./mondbfile.sql
Add your comment

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