I often interactively loop over e.g. my files and want to perform a specific operation on all of them, let\'s say I\'d like to rename all files:
for file in
This thread would tell you why the option to show commands instead of executing those (a.k.a dry run) would never be implemented for bash.
Refer to the response from Eric Blake:
>My question is why can't such an option or be provided,A little thought would show why this will never be implemented. What would such an option output for the following:
if complex_command; then foo=command1 else foo=command2 fi $foo argsOn the line for
$foo args, there is no way to know what$fooexpands to unless you have previously executed (not just scanned) thecomplex_command. Therefore, there is no way to dry run what the final results will be without running things, but running things is counter to the goal of a dry run.That said, you might be interested in the
bashdbproject, which uses bash hooks to provide a debugger interface where you can single-step through a bash script; it's not the same as telling you what the script would do, but it at least lets you control how much or little of the script is actually run.