Bash script to check available updates

WP-CLI and AWK

One way is to do the counting of the available string in the third column via AWK:

wp plugin list | \
 awk 'BEGIN{N=0;} \
  ($3=="available"){N++; print $0;} \
  END{print(N>0)?"Plugin updates available: "N:"No plugin updates available";}'

where N is the number of available updates, in case you need the number, $0 is the whole row and $3 the third column.

Example output:

Foo-plugin    active  available       1.2.3
Plugin updates available: 1

Similar for themes.

WP-CLI and PHP/WordPress API

Another way is to do this via a PHP script, that includes the relevant WordPress API calls and run it like:

wp eval-file script.php

or as a custom WP-CLI command.

See e.g. my answer here and here.