> For the complete documentation index, see [llms.txt](https://sugar-at.gitbook.io/blog-article/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sugar-at.gitbook.io/blog-article/shell/function.md).

# 7. 函数

```bash
fname(){
    command
        …
    command;
}
# 使用函数时，只需输入以下命令：
# fname[ parm1 parm2 parm3 …]
```

demo1

```bash
# param1 name
hello(){
    echo "hello $1"
}

hello "小明"
```

输出

```
hello 小明
```
