Is there a generic way of running a bash script and seeing the commands that result, but not actually run the commands - i.e. a "dry run"/simulator of sorts?

I have a database install script (actually "make install" after running ./configure and make) that I wish to run, but it's installing all sorts of stuff that I don't want.

So I'd like a way to see exactly what it's going to do before I run it for real - maybe even run the commands by hand instead.

Is there any utility that can perform such a task (or anything related/similar)?

  • I think 'set -n' does something like that. Try adding -x as well.
    – Jeff Schaller
    Apr 11, 2016 at 21:58
  • How do I pipe "make install" to set -n?
    – Vérace
    Apr 11, 2016 at 22:23
  • bash -n make install, but from man bash: "An interactive shell may ignore this option."
    – pfnuesel
    Apr 11, 2016 at 22:35
  • There is no dryrun option in bash. See also here stackoverflow.com/questions/19115156/…
    – pfnuesel
    Apr 11, 2016 at 22:35

2 Answers 2


GNU make has an option to do a dry-run:





“No-op”. Causes make to print the recipes that are needed to make the targets up to date, but not actually execute them. Note that some recipes are still executed, even with this flag (see How the MAKE Variable Works). Also any recipes needed to update included makefiles are still executed.

So for your situation, just run make -n install to see the commands that make would execute.

  • 1
    BTW, the -n, --justprint, --dry-run and --recon options also all work in CMake. You can check this using cmake --help or man cmake. The four options seem to be equivalent/synonymous.
    – GPWR
    Jun 26 at 20:25

Any version of make has a -n option (see POSIX description of make), but the shell has no corresponding option (see for example Show commands without executing them).

To aggravate the situation, if you happen to use automake, it pastes-in large chunks of boilerplate scripting (which its developers refer to as "recursive rules") which defeat the ability of anyone to use "make -n" and see what will happen.

Further reading:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .