# "Debug" mode



> $ cat hello.sh
>
> ```
> !/bin/bash
> echo "Hello World" 
> ```

> bash -x hello.sh
>
> echo Hello World&#x20;
>
> Hello World

`-x` 參數使您可以依序執行腳本中的每一行，了解執行流程。這裡有一個很好的例子：

$ cat hello.sh

> !/bin/bash
>
> echo "Hello World\n"&#x20;
>
> adding\_string\_to\_number="字串"&#x20;
>
> v=$(expr 5 + $adding\_string\_to\_number)
>
> $&#x20;

```
./hello.sh 
Hello World
expr: non-integer argument
```

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

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