Using Jeremy's amazing example here http://lists.xymon.com/pipermail/xymon/2013-January/036615.html I'm trying to do something a little simpler...
Basically, if the line contains "debug:" replace it and the rest of the line with "DEBUG LINE DETECTED AND REPLACED". Otherwise just output the log normally.
Here is what I have tried and the part within the backticks works fine (if I exclude the exec part that hangs my bash session) from a command line to produce the name of the file:
log:exec 2>/dev/null; F=/path/to/file/log.log; T=/tmp/substitutedlog.log; C=$(sed 's/debug:.*/DEBUG LINE DETECTED AND REPLACED/' $F > $T); echo $T:1024
log:exec 2>/dev/null; F=/path/to/file/log.log; T=/tmp/substitutedlog.log; sed 's/debug:.*/DEBUG LINE DETECTED AND REPLACED/' $F > $T; echo $T:1024
log:exec 2>/dev/null; F=/path/to/file/log.log; T=/tmp/substitutedlog.log; sed "s/debug:.*/DEBUG LINE DETECTED AND REPLACED/" $F > $T; echo $T:1024
log:F=/path/to/file/log.log; T=/tmp/substitutedlog.log; sed "s/debug:.*/DEBUG LINE DETECTED AND REPLACED/" $F > $T; echo $T:1024
But /usr/share/xymon-client/logs/xymonclient.log gets this:
sh: -c: line 0: unexpected EOF while looking for matching `'' sh: -c: line 1: syntax error: unexpected end of file
Or this:
sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file
...depending on whether I use single or double quotes in the sed expression.
Kind regards,
SebA