I believe the core of this problem is related to POSIX compatibility. grep
is a tool that is specified by the POSIX standard. As schily points out in the comments, the POSIX specification of grep
does not include the --include
or --colour
options. In fact, these options are part of GNU grep
, which adds a lot more features to grep
over and above what is mandated by the POSIX specification. The GNU grep
manual can be found here: https://www.gnu.org/software/grep/manual/grep.html
On Solaris, the default grep
tool is another POSIX-compatible implementation that is provided by Sun/Oracle. Naturally, that implementation does not support either of the options required here. The manpage for Solaris 10 can found here, and the one for Solaris 11 can found here.
This limitation goes beyond the grep
command on Solaris. For example, the date
command on Solaris is a lot less flexible compared to GNU date
. The ps
command on Solaris 10 also chops off process command-lines at 80 characters. As a solution/workaround to these problems, the GNU tools were eventually made available on Solaris 10 & 11. This QA goes into a lot more detail about where they can be found and how they can be installed.
When the GNU tools are installed on a Solaris system, and the name of the tool is already in use, a g
is prefixed to command name. So, date
becomes gdate
, grep
becomes ggrep
and so on. In your case, the problem could be solved by using the ggrep
command because it supports the required GNU-specific options (or extensions).
A possible problem here is that a Solaris system need not have the GNU tools installed. Some additional work is required to install these packages. If the GNU tools are not present on the target, then the ggrep
command would simply be unavailable.
In general, a solution that aims for portability across POSIX distributions takes the opposite approach. Instead of using tools specific to each platform, the solution is intentionally modified to adhere to the POSIX specification, and to not use any extensions that are specific to any certain implementation. This is typically the only way to ensure that the solution works consistently across all POSIX-compatible systems.
solaris man grep
shows two variants for grep, neither of which lists--include=
or any recursion. You probably need afind
piped into grep with the-f -
(filenames from) option. – Paul_Pedant Oct 23 '20 at 10:50--include
as well as-r
. But indeed, onunix.stackexchange
I found several answers which recommend the use offind
. – Stéphane Laurent Oct 23 '20 at 10:56grep
, see: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html – schily Oct 23 '20 at 11:44ggrep
instead (see my previous comment). This is the same as the more commongrep
command. – Stéphane Laurent Oct 23 '20 at 11:48grep
manual on that site, too. – JdeBP Oct 23 '20 at 12:14