Is there a quick and dirty way to not only log the output of a shell file but the commands used inside as well?For example:whoami > who.dmpwould output a file that contained something like:my_usernameFor a longer shell file, what is the most effective way to display the command that caused the result in the log file as wellEx:log.txt###############echo whoami  <- I want this to show in the file as wellmy_usernametime   <- I want this to show in the file as wellreal    0m0.00suser    0m0.00ssys     0m0.00sIs there a way to do this without hard-coding exporting the command into the output file every single time?
Show command executed along with output in log file
shell script;logs;io redirection
Using the shell built-in set -x is probably the cheap-and-dirty way to do this. In shell scripts you will often see a line like:#set -xWhich someone left behind by just commenting it out.  I think you could use that at the interactive command line, but you may not like what it does there.