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\n
expr: non-integer argument

The error above is not enough to trace the script. Running it the following way gives you a better sense of where to look.

$ bash -x hello.sh 
+ echo 'Hello World\n'
Hello World\n
+ 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