首先:
1、编写一个hello.sh的程序
hello.sh
vim hello.sh
#!/bin/sh
#作者:yangyx
echo “hello shell”</span>
编写完成,接下来我们还需要对她赋予权限
chmod a+x hello.sh
然后./hello.sh
即可在终端看到结果:hello shell
2、在shell脚本中使用read命令
hello.sh
vim hello.sh
#!/bin/sh
#作者:yangyx
echo “hello world”
read PATH #读进一个PATH的值
echo “hello $PATH” #将PATH的值通过打印出来
同样的,chmod a+x hello.sh
然后运行: ./hello.sh
3、定义变量
hello.sh
vim hello.sh
#!/bin/sh
name = "yangyuanxin"
echo $(name)
同样的,chmod a+x hello.sh
然后运行: ./hello.sh