Make a Bash script echo executed commands

You can debug the script with -x, which will echo the commands and arguments.

bash -x script.sh

You can do this for specific portions of the file, too (from section 2.3.2 linked above):

set -x          # activate debugging from here
ssh user@example.com ...
set +x          # stop debugging from here

The output from -x might be a bit too verbose for what you’re looking for, though, since it’s meant for debugging (and not logging).

You might be better off just writing out your own echo statements – that’d give you full control over the output.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)