Why isn't $KMVAR variable displayed in terminal with an echo command?

Two different scopes, I think. The shell environment invoked in a KM script action is not the same as that invoked by terminal.app. Slightly different shells, and they don't automatically share environment variables.

I think you will see your variable if you run an echo command from a KM Execute Shell Script action.

(compare the output of the printenv command in both (terminal.app and KM shell action), including the values of variables like $PATH and $LANG, which are not automatically exported)

PS Peter's update at the bottom of this thread is helpful:

1 Like