#!/bin/bash -x
echo This is a script that has debugging turned on
This script outputs
+ echo This is a script that has debugging turned on
This is a script that has debugging turned on
I want to get rid of these +'s by deleting them or replacing them. I expected sed could fix my problem (sed 's/^\++//g') -- But this approach doesn't affect the debug output lines.
With some more experimenting, I discovered that the debug output seems to be getting written to stderr (inferred this with the command ./test.sh 2>/dev/null which the output then excludes the debug lines)
With this new information, I would expect this to work
./test.sh 2>&1 | sed 's/^\++//g'
But, alas, I still get the same undesired output:
+ echo This is a script that has debugging turned on
This is a script that has debugging turned on