DEV Community

Dênis Mendes
Dênis Mendes

Posted on

bash script - Check if environment variable was set.

Here's how you check if a environment variable was set using a bash script:

#!/bin/bash

if [ -z "$AWS_ACCESS_KEY_ID" ]; then
  echo "You need to set AWS credentials! Check out the project documentation."
  exit;
fi
Enter fullscreen mode Exit fullscreen mode

This script is working on macOS Catalina.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay