Although Bash scripting is not a full fledged compile-able programming language, it is still very powerful and the script size can grow to enormous size. Therefore, even when you are just occasional bash scripting user or complete beginner some techniques is good to know in order to help debug you bash code. In this article we list some most command and basic bash scripting debbuging techniques.

The first debugging technique is bu using -x bash option during script execution. This will print all lines of code that is execute. For an illustration let's consider a following example:

echo hello

echo $myvar
To debug this bash shell script use -x bash option during script execution:
$ bash -x 
+ echo hello
+ myvar=3
+ echo 3

Next and very common bash scripting debugging is to use echo command. Place echo command on each line to print variable content or even entire line of code to see what is being execute and what follows. This has already been illustrated in the above code example echo $myvar.

Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top