What does Linux watch -g or –chgexit option do?

You can use watch -g or–chgexit option to exit when the output of the command changes. By default, the watch command displays till the data stream stops or is forced to exit.

Example:

Create and execute a script that inserts 1 item every 2 seconds indefinitely:

watch -g or –chgexit option example: