In bash, when running with the -x
option, is it possible to exempt individual commands from echoing?
I'm trying to make the output as neat as possible, so I am running certain parts of my script in a subshell with set +x
. However, the row set +x
itself is still echoed and adds no valuable information to the output.
I remember back in the bad old .bat
days, when running with echo on
, individual lines could be exempted by starting them with a @
. Is there any equivalent in bash?
#!/bin/bash -x
function i_know_what_this_does() {
(
set +x
echo do stuff
)
}
echo the next-next line still echoes 'set +x', is that avoidable?
i_know_what_this_does
echo and we are back and echoing is back on
When running the above, output is:
+ echo the next-next line still echoes 'set +x,' is that 'avoidable?'
the next-next line still echoes set +x, is that avoidable?
+ i_know_what_this_does
+ set +x
do stuff
+ echo and we are back and echoing is back on
and we are back and echoing is back on