We can transcript and run multiple commands in one single bash script file, but it won’t print the command you wrote in script by default.
Whereas, printing commands in script is supported, it just need to be enabled by adding The Set Builtin.
Print shell input lines as they are read.
Value of variables won’t be print out, it’s safe in this way to protect your
secrets like password or token.
bash -v <YOUR_SCRIPT>
Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.
NOT recommend any one to use xtrace in
production, for your secrets passed in variables like password or token might be cached in log or somewhere else, they might be leaked.
bash -x <YOUR_SCRIPT>