Reading Java Properties Files from Bash

2004-11-03 / All Blog posts

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, massages it into a format that is compatible with bash syntax, writes it to a temporary file and sources it.

sed -re 's/"/"/'g|sed -re 's/=(.*)/="\1"/g'>$TEMPFILE
source $TEMPFILE

After running this script, all of the properties in the Java properties file become available as environment variables.

comments powered by Disqus