According to Add tack e x on your bash shebang | #!/bin/bash -ex
Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’.
-eExit immediately if a command exits with a non-zero status.
-xPrint commands and their arguments as they are executed.In short, adding
-exto your#!/bin/bashwill give verbose output and also will abort your script immediately if part of the script fails.