In this article, we will see how to debug a bash shell script in Linux.
In bash shell, when we need to check step by step what happens in a script, we can use debug mode in linux to investigate the script.
In order to activate debug mode in bash shell, "-x" flag is added to bash shell declaration part, at beginning of script.
#!/bin/bash -x
# output to file from parameter
Lets see it in shell example.
As above output indicates, we called a shell bash script with name "1.sh", and we called it. Due to "-x" flag in beginning of script, it executes each line as line by line as debug mode.