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