Published 2004-11-03.
Time to read: 1 minutes.
Ever notice that Java properties files are fairly similar to bash scripts?
Here is a short bash script that takes a valid Java properties file called language.properties
,
massages it into a format that is compatible with bash syntax, writes it to a temporary file and sources it.
Shell
#!/bin/bash TEMPFILE=$(mktemp) cat language.properties | \ sed -re 's/"/"/'g | \ sed -re 's/=(.*)/="\1"/g' > $TEMPFILE source $TEMPFILE rm $TEMPFILE
After running this script, all of the properties in the Java properties file become available as environment variables.