Skip to content

Instantly share code, notes, and snippets.

@marcelbirkner
Created March 7, 2016 13:19
Show Gist options
  • Save marcelbirkner/9b133f800d7d3fc5d828 to your computer and use it in GitHub Desktop.
Save marcelbirkner/9b133f800d7d3fc5d828 to your computer and use it in GitHub Desktop.
Read property from properties file within Shell Script
#!/bin/sh
PROPERTY_FILE=apps.properties
function getProperty {
PROP_KEY=$1
PROP_VALUE=`cat $PROPERTY_FILE | grep "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}
echo "# Reading property from $PROPERTY_FILE"
REPOSITORY_URL=$(getProperty "nexus.repository.url")
@vitalii-movchan-mesh
Copy link

vitalii-movchan-mesh commented Dec 24, 2024

Taking into account SC2002, use:

grep "$PROP_KEY" "$PROPERTY_FILE" | cut -d '=' -f2

Thanks for example, @marcelbirkner, really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment