This is an extension to the question In a shell script: echo shell commands as they are executed.
So we have our command line echo'd either by using set -v
(for verbose, before expansions), or set -x
(for xtrace, after expansions); or both set -vx
. Great.
My question is: how do we redirect those echo'd lines (to a file, for instance)?
If I run the following lines,
BLA='xyz'
set -v
echo $BLA > bla.log
, clearly, bla.log
will contain 'xyz
', not the echo 'echo $BLA > bla.log
'.
I clearly need a better/depper understanding about the shell to see what is going on here; would appreciate very much a deeper explanation besides the 'howto redirect' solution.
Thanks