Your syntax has many problems:
remove spaces around "=" when setting a variable
wrong:
APP_ID = valueright:
APP_ID=valueadd spaces around everything when using "[", and you need a semicolon or newline after the "]". This is because "[" is a command also known as "test" (see
man test), which just like other commands, takes its arguments separated by space:wrong:
if[x!= y] then echo hello world firight:
if [ x != y ]; then echo hello world; fiuse double quotes, not single quotes when you want to expand a variable
wrong:
if [ '' != '${APP_ID}' ]; thenright:
if [ '' != "${APP_ID}" ]; thenAlso for the above example, you can use -n (non-empty) instead of comparing to empty string
if [ -n "${APP_ID}" ]; thenAnd for the ps example, you don't need grep and awk:
APP_ID=$(ps -C whoami --no-header --format 'pid')
And so here is the fixed up script:
APP_ID=$(ps -C whoami --no-header --format 'pid')
if [ -n "${APP_ID}" ]; then
echo "Stopping instance $APP_ID"
fi