Skip to content

Instantly share code, notes, and snippets.

@scottalan
Last active December 24, 2015 12:59
Show Gist options
  • Save scottalan/6801794 to your computer and use it in GitHub Desktop.
Save scottalan/6801794 to your computer and use it in GitHub Desktop.
script
#!/bin/bash
# Variables
rand=$RANDOM
web_user=$USER
prefix=DB_
# My ENV variable is: DB_scotttest=scott-cedistage_13250
# Let's say [ ${1} -e 'test' ]
# I'm trying to dynamically build the name of my ENV variable in my script.
if [ -z "${db}${web_user}${1}" ]; then
database=${web_user}-${1}_${rand}
else
database=$db$web_user$1
fi
echo -e "${YELLOW}-----Database is: ${GREEN}$database${RESTORE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment