What is the best way to set up a Bash script that prints each command before it executes it?

That would be great for debugging purposes.

I already tried this:

CMD="./my-command --params >stdout.txt 2>stderr.txt"
echo $CMD
`$CMD`

It’s supposed to print this first:

./my-command --params >stdout.txt 2>stderr.txt

And then execute ./my-command --params, with the output redirected to the files specified.

4 Answers
4

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *