Is there an easy way to make whois queries from the terminal have syntax coloring in the output so it would be easier to read?

Something basic like coloring NOT FOUND in red, and field names and dates in different colors would already be useful. It doesn't matter if the coloring is not 100% accurate.


The program, grc, is "the frontend for generic colouriser grcat." The project exists at GitHub, but it might be installed from a repository, if your O/S has packaged the software. Many commands come preconfigured, and it can be customized to colorize any command.

A portion of output is shown below for the command, whois stackexchansssssssge.com.

grc whois output

To incorporate the caveat noted in the comments, please note that one can abbreviate the command, grc whois <arg>, with the command, whois <arg>, by sourcing the appropriate script that comes with the software. This script (one of grc.zsh, grc.bashrc, or grc.fish, according to the corresponding shell in use) establishes aliases for the configured commands that prepend each configured command with grc --colour=auto.

The software has preconfigured color for the following commands.

  • cc
  • configure
  • cvs
  • df
  • diff
  • dig
  • gcc
  • gmake
  • ifconfig
  • last
  • ldap
  • ls
  • make
  • mount
  • mtr
  • netstat
  • ping
  • ping6
  • ps
  • traceroute
  • traceroute6
  • wdiff
  • whois
  • iwconfig

Accomplish the Goal Without Color

In Linux, at least, note also that the exit code from whois should be 0 when a domain name was found and 1 when a domain name was not found.

whois stackexchange.com
echo $?

This produces an exit code of 0 - found.

whois stackexchansssssssge.com
echo $?

This produces an exit code of 1 - not found.

Or, to deduce the same with no output from whois, try as follows, using ; to assure output of the exit code.

whois stackexchange.com >&- ; echo $?
whois stackexchansssssssge.com >&- ; echo $?
  • grc whois is just the kind of thing I hoped for, that's awesome! I just realized that it would be easy to write Emacs/Vim syntax rules too, but grc does the job just fine.
    – Lassi
    Apr 10 '19 at 21:29
  • 1
    Ah! Yes... grc whois. In order to type merely whois for the same result, one could source the right file for the shell in use, e.g: grc.zsh, grc.bashrc, grc.fish. This action establishes the aliases to prepend grc --colour=auto to commands. Apr 10 '19 at 21:36
  • Yes, but even grc whois is already extremely easy. I almost miss the good old scrolling through a grey wall of legal mumbo jumbo and miscellaneous names and numbers :)
    – Lassi
    Apr 10 '19 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.