Hello World in Debug mode

suggest change
$ cat hello.sh 
#!/bin/bash 
echo "Hello World"
$ bash -x hello.sh 
+ echo Hello World
Hello World

The -x argument enables you to walk through each line in the script. One good example is here:

$ cat hello.sh
#!/bin/bash 
echo "Hello World\n" 
adding_string_to_number="s"
v=$(expr 5 + $adding_string_to_number) 

$ ./hello.sh 
Hello World

expr: non-integer argument

The above prompted error is not enough to trace the script; however, using the following way gives you a better sense where to look for the error in the script.

$ bash -x hello.sh 
+ echo Hello World\n
Hello World

+ adding_string_to_number=s
+ expr 5 + s
expr: non-integer argument
+ v=

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents