When a script should only run if a certain plugin is on, parsing wp plugin list is clumsy. There is a command that only answers that question.
if wp plugin is-active woocommerce; then
wp wc tool run clear_transients --user=admin
fi
The exit code is 0 when the plugin is active and 1 when it is not. Nothing is printed, so it fits straight into an if or an && chain. To test it by hand, run echo $? right after it.
On a multisite network there are two kinds of active. wp plugin is-active akismet --network asks whether the plugin is network-activated. Without --network, and with --url pointing at a subsite, you ask about that one site.
The name is the plugin slug, the folder name you see in wp plugin list, not the title on the Plugins screen. And “not active” includes “not installed”. If a plugin is missing but still listed in the active plugins option, WP-CLI prints a warning, which I find a nice hint that someone deleted a plugin folder by hand.
Further reading: wp plugin is-active