# shell学习笔记二  参数和环境变量

- URL: https://www.yidoo.xyz/shell-study-notes-two-parameters-and-environment-variables
- 作者: 核动力蜗牛
- 发布时间: 2009-09-25
- 更新时间: 2009-09-25
- 分类: 技术笔记
- 标签: shell

这次要学习一下，参数和环境变量

```bash
#!/bin/sh
echo "The program's name is $0"
echo "The first parameter is $1"
echo "The second parameter is $2"
echo "The parameter list is $*"
echo "The user's home directory is $HOME"
exit 0
```

在终端中输入：./ex_02.sh hello killua

执行结果：

```bash
The program's name is ./ex_02.sh
The first parameter is hello
The second parameter is killua
The parameter list is hello killua
The user's home directory is /home/killua
```

PS:主要环境变量都是大写的，写$Home 程序不会报错，但是没有结果
