Let's say I had a loop in terminal that created a set of directories, performed a set of tasks, and I wanted for each command family of commands to be written to log files in a new directory. This can be achieved in a few ways (using echo/going with python), but I was wondering is there any easy way to easily pass a command at the front of my loop that just will automatically create a log file in the new directory of the commands the loop runs. EDIT: By a log file here I mean to only collect the final commands that are passed to the terminal.
Part of the motivation for this is that I'm going to be randomly generating fluctuations in the parameters I pass in my commands, and it'd be much to just be like "flag the following commands in this loop for logging" vs having to assign variable values and then echo them. Learning if there is a sort of "log" command would be helpful in many other scenarios, so I'd prefer answers to that effect.