Month: June 2015

Working with Neo4j, I wanted to simplify turning on/ off debugging via the Neo4j properties file, so I decided to use sed to do this. This code is just the sed lines to do this.

This has the infamous OS X -i ‘’ argument to do the substitution in place.

# This is the line I either want - to don’t want - in my neo4j-wrapper.conf file:
DEBUG_CONFIG="wrapper.java.additional=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y"
sed -i '' "/\(^${DEBUG_CONFIG}$\)"'/d' ./neo4j-wrapper.conf
# This is the line after which I will add my debug config line
MATCH_LINE="wrapper.java.additional=-XX:-OmitStackTraceInFastThrow"
# After the match line, append the Debug configuration.
sed -i '' "/\(^${MATCH_LINE}$\)"'/a\'$'\n'"${DEBUG_CONFIG}" ./neo4j-wrapper.conf