> For the complete documentation index, see [llms.txt](https://kawsing.gitbook.io/opensystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled-4/shell-script/debug-mode.md).

# "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=
```
