


Using set -x inside script for the specific script. So let us have a look at debugging only some specific part of a script in the Next way of Debugging.Ģ. One slight drawback with this is there is a need to perform debug checks on the entire script, if the script is huge it is quite tough/tedious to find useful insights from the output of -x option.
#Shell script debugger code
In the above code all comments and code are visible (like the entire “if block” and not only the lines which are executed).
#Shell script debugger mod
# Calculate remainder using mod (%) operatorĮcho "You have entered $n - which is an Even number'Įcho "You have entered $n - which is an Odd number"įigure 5: View Comments and Code while they are executing in OddEven.sh Let’s understand its application using the example below which has OddEven.sh Script which by purpose has a small syntax error. So this option helps with getting syntax checks performed on a script using CLI (Command Line Interface). It is difficult to have GUI (Graphical User Interfaces) or designated IDEs (Integrated Development Environments) on Virtual Machines executing in the cloud. With a boom in the technology of cloud computing, it is essential to know various command-line options to check syntax errors. -n: It helps in checking the syntax errors if there are any in the shell script prior to executing it.Similar to the prior example each line of code is traced before it is executed. Just like all the other programming/coding languages debugging is crucial in bash/shell scripting in order to understand the flow of the program and resolve any errors if they occur.įigure 2: Tracing OddEven.sh Output using -x option of bash. DevOps (Operations Team responsible for deployment more often) use Bash/Shell scripting (series of commands written in a file to execute together in an ordered fashion) to automate usual/minimalist/trivial tasks for example running checking of time stamps on which file is generated/updated, checking for a number of files, etc.ĭebugging is terminology that means the process of identifying errors and possibly resolving them in computer hardware or software. Major Linux distributions (often referred to as Linux distros) are Open Source (Source Code available and can be modified on request) in nature like Ubuntu, CentOS, etc.īash is a very popular shell scripting language that is executed in the back-end when you open the terminal in Linux. Linux is a very popular operating system especially among developers and in the computer science world, as it comes along with its powerful ability to play with the kernel.
#Shell script debugger how to
