Is there a way to hide a command from the output with xtrace on (set -o xtrace)?
In DOS, the technique is to turn echo on but prefix the hidden commands with the @ symbol.
I've never seen a similar trick in bash, but you can sometimes use subshells to temporarily enable tracing for commands you're interested in:
echo "This command is not traced"
(
set -x
echo "This command is traced"
)
echo "No longer traced"
If subshells are not suitable because you want to modify the environment, you can set -x and then set +x, but that leaves you with the artifacts of tracing set +x commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With