Skip to content

Instantly share code, notes, and snippets.

@Alexhha
Last active Apr 18, 2017
Embed
What would you like to do?
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
if [[ "A" == "A" ]]; then
sed -r "s/^(#)?labels=.*/labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}/" newrelic.cfg | grep labels
fi
SED_REPLACE_EXPR="labels=PROJECT:Venice;SERVER-STACK:${APP_NAME}-${ENV};EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}"
SED_MATCH_EXPR='s/^(#)?labels=.*'
if [[ "A" == "A" ]]; then
sed -r "${SED_MATCH_EXPR}/${SED_REPLACE_EXPR}/" newrelic.cfg
fi
SED_REPLACE_EXPR="s/^(#)?labels=.*/labels=PROJECT:Venice;\
SERVER-STACK:${APP_NAME}-${ENV};\
EC2-TYPE:${INSTANCE_TYPE};VPC:${VPC_ID}"
sed -r "${SED_REPLACE_EXPR//[$'\t\r\n ']}/" newrelic.cfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment